Method to change self-closing tags to explicit tags in Javascript? <p>Does there exist a method or function that can convert the self-closing tags to explicit tags in Javascript? For example:</p> <pre><code>&lt;span class="label"/&gt; </code></pre> <p>converted to :</p> <pre><code>&lt;span class ="label"&gt;&lt;/span&gt; </code></pre> <hr> <p>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.</p> <hr> <h2>And this html is in a string</h2> <p>In fact, I don't want to parse HTML, I just want to find the "&lt; span.../>"and replace it with "&lt; span...>&lt; /span>"</p>