Reputation: 3556
I am extracting content from an HTML textarea using JS, in order to then put it into a <div>
. Now, I know the content is going to be valid HTML - so I assumed that if I set it as the innerHTML of another element it would be parsed by the browser - but it's not. I'm getting the plain string (with tags and all) on the screen.
This is basically my script:
var txt = document.getElementById("contentTextArea").innerHTML; //Get the content
document.getElementById("contentOutput").innerHTML = txt;
Here's the HTML, just to be sure:
<textarea name="content" id="contentTextArea">
<p>Text...</p>
</textarea>
What am I doing wrong? Is there another way of doing this? Thanks!
Upvotes: 0
Views: 94
Reputation: 2157
var txt = document.getElementById("contentTextArea").value;
//Get the content
Upvotes: 3
Reputation: 12335
Textareas support value
not innerHTML
. YOu should do this...
document.getElementById("contentTextArea").value;
Upvotes: 2