JavaScript - Use innerHTML as actual html instead of plain text -


when i'm trying change document.documentelement.innerhtml using innerhtml of textarea this:

document.documentelement.innerhtml = document.queryselector('#mytextarea').innerhtml 

the innerhtml of #mytextarea not used actual html change dom, plain text.

for example: if innerhtml of #mytextarea <p>a paragraph</p>.

then document after loading looks like: <p>a paragraph</p> instead of a paragraph

how should value inside #mytextarea used change dom? (ex. appending new elements)

use .value contents of textarea without being encoded.

document.getelementbyid("documentelement").innerhtml = document.queryselector('#mytextarea').value;
<textarea id="mytextarea">  <p>a paragraph</p>  </textarea>  <div id="documentelement">    </div>


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo