How does jquery or php check whether dom elements are closed? for example, my dom is complicated & lt; div & nbsp; class = "I _curr_content" & nbsp; style = "DISPLAY: & nbsp; block "& gt; & nbsp; // This div is not closed & lt; how does h3 jquery or php check whether the dom element is closed?
For example, my dom is complicated.
// This div 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:
------ 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 div 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 div is not closed
Eight super food types that are resistant to stress, eat at pressure!