Try:
$('p')
.filter(function() {
return $.trim($(this).text()) === '' && $(this).children().length == 0
})
.remove()
What that does is it finds all the <p>
s that have nothing in them, and removes them from the DOM.
Try:
$('p')
.filter(function() {
return $.trim($(this).text()) === '' && $(this).children().length == 0
})
.remove()
What that does is it finds all the <p>
s that have nothing in them, and removes them from the DOM.