How does jquery or php check whether dom elements are closed? for example, my dom is complicated & lt; div & nbsp; & gt; & nbsp; this div is not closed & lt; h3 & gt; & lt; a & nbsp; hre jquery or php. how can I check whether the dom element is closed?
For example, my dom is complicated.
// This p is not closed
Eight super food types that are resistant to stress, eat at pressure!
As we all know, too much pressure will undermine our eating habits, 2112132123
How can php or jquery find the html element that is not closed and add it to it?
?
Share :?? // This p is not closed
------ Solution --------------------
Read with DOMDocument: loadHTML and write it with DOMDocument: saveHTML
It is automatically completed, but note that the html document must have Flag. if not, add it by yourself.
For example, your section (assuming it is gbk)
$ S = <HTML
// This p is not closed
Eight super food types that are resistant to stress, eat at pressure!
As we all know, too much pressure will undermine our eating habits, 2112132123
HTML;
$ S ='
'. $ S;
$ Doc = new DOMDocument;
$ Doc-> loadHTML ($ s );
Echo $ doc-> saveHTML ();
Output
// This p is not closed
Eight super food types that are resistant to stress, eat at pressure!