Remove div without class when contains custom element with jquery -
i'm trying remove stray elements. have no class
or id
attributes whom have custom element without id
or class
attribute. there cases custom element have class name.
the p should remain, have either text or video element.
$("p:contains("$("getimage")")").remove();
is there better way work?
edit
"getimage" custom tag.
<div class="ajaxposttext"> <p><getimage style="display:none;" height="360" width="640" src="http://localhost:8888/localtesting/wp-content/plugins/wp-o-matic/cache/687a91dca2_ku-xlarge.jpg" class="transform-ku-xlarge"></getimage></p> <p>movies long. film masterpieces can shave off few minutes here , there can off our butts, away laptops, out of theaters, eyeballs off tv little bit earlier. so. how short can movie gist of it? can done in 9 single frames?</p> </div>
this remove p tags without id , class. included demo sample getimage tag too.
demo
$('p').not('[id],[class]').remove();
if want remove elements inside container.
$('*','.containerselector').not('[id],[class]').remove();
for specific example have provided try this:- demo
$('*', '.ajaxposttext').not('[id],[class]').remove();
more filter:- remove p tags no id, no class, no text. demo
$('p', '.ajaxposttext').not('[id],[class]').filter(function(){ return $.trim($(this).text()) === '' }).remove();
Comments
Post a Comment