javascript - How to delete an element in jQuery with a specific child? -
html:
<p><br style="clear:both;"></p>
i'm using wikipedia api project, , i'm cleaning wikipedia's raw html output , i've been struggling problem. how remove specific <p>
element dom jquery using .remove();
? want <p>
element <br style="clear:both;">
inside of removed.
thanks in advance! i've been struggling problem.
suppose child br
itself, code -
$('p>br').closest('p').remove();
or use
$('p>br[style="clear:both;"]').closest('p').remove();
or use parent function
$('br[style="clear:both;"]').parent('p').remove();
but don't make it
$('br[style="clear:both;"]').parent().remove(); // don't use
because there may many br
possible in dom
parent not p
Comments
Post a Comment