The WordPress word editor spits out empty <p> tags like this: <p> </p>.
I would like to target all <p> with in them and remove them. I believe I have to use the contains and remove functions but I am not sure if this code would remove the <p> tags with only in them or remove all <p> tags with in them anywhere.
jQuery('p:contains(" ")').remove();
How would I make this work?
you can use .filter and look if the innerHTML is equal to :
$("p").filter(function(){
return $.trim(this.innerHTML) === " "
}).remove();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With