How to remove empty <p>...</p> but with possible attributes?
Assume I have the following simplified source code:
- <p> </p>
- <p style="line-height: 12px;"> </p>
Both <p>s contain inside only whitespace chars. Here it is a blank. It could be a tab or nbsp as well.
Now I wan to remove all empty <p>s resp all those which contain only whitespaces.
When I try the following (pure Javascript) code:
- document.body.innerHTML=document.body.innerHTML.replace(/<p>(\s*| |&tab;)<\/p>/g,"");
then only the first <p>...</p> is removed.
How can I extend the command that the second <p .....>...</p> is covered as well?
Is there a better jQuery command?