Using javascript and jQuery, parse to find, then remove <p> Â & nbsp; </p> when you find in the html document

I have a trusted source that sometimes returns an html that contains this: <p>Â&nbsp;</p> , which appears on my page as "Â". It does not have a class or id to help me select and delete it. I cannot reliably use a child selector, for example li > p , or add a class to p .

Is there a way to parse the html page for p tags with relevant content and then delete?

I found this solution a similar problem, but it does not work for me. Perhaps this is the wrong approach for me: JavaScript: how to remove HTML tags from a string?

+4
source share
2 answers

Try

 $(document.body).html($(document.body).html().replace('Â', "")); 

WORKING DEMO

0
source

Something like that:

 $("p:contains(Â):not(:has(p))").remove(); 
+2
source

Source: https://habr.com/ru/post/1486046/


All Articles