var originalHtmlString = '<p>Some text</p>'

        //Create an html object called myHtml that I can work with like w/ document
        var myHtml = document.createElement( 'html' );

        //Make the html object hold the html I wrote in a string so I can edit it as html
        myHtml.innerHTML = originalHtmlString;

        var stringifiedHtml = ???

如何在使用“myHtml”变量后将其转换回字符串?

最佳答案

应该很容易

var stringifiedHtml = myHtml.outerHTML;

Element.outerHTML

07-25 22:02