Does there exist a method or function that can convert the self-closing tags to explicit tags in Javascript?
For example:
<span class="label"/>
converted to :
<span class ="label"></span>
I would like to copy a new HTML from the iframe to the outerHTML of the main page, as the new HTML generated contains self-closing tags, the outerHTML doesn’t recognize them and then doesn’t change and the page doesn’t show correctly. But when the format is standard, that is,with the non-self-closing tags, the outerHTML will take the new HTML,and the page shows perfectly.This is why I would like to change the tags.
And this html is in a string
In fact, I don’t want to parse HTML, I just want to find the “< span…/>”and replace it with “< span…>< /span>”
Thanks all, I finally use the silly method to change the self-closing tags, maybe it’ll help someone like me: