For some reason wordpress randomly inserts “blank” paragraph tags on my page. I’m finding it difficult to match the tag.. It seems like it’s not completly empty but some weird character I cannot see, it’s not there in the source code but generated by javascript so it’s very hard to figure out what it is!!
My JS file is loaded last in <head>.
I’m new to regex in javascript..
it looks like this in firebug (not sure if there is a small space/tab/something or not)
<p></p>
My javascript to remove it:
jQuery(window).load(function() {
var page = jQuery('body').html();
page.replace('/\<p\>\S*\<\/p\>/', '');
jQuery('body').html(page);
});
Use jQuery
emptyselector instead which select all elements that have no children (including text nodes). Try this.