I am developing some kind of online html editor and I have a problem with getting the content of a textarea with jQuery.
The Textarea element is like this:
<textarea id="myText"><b><p>TEST</p></b></textarea>
So it is a mixture of escaped and unescaped text. However, the browser shows the textarea like this, which is also something that I don't want :
<b><p>TEST</p></b>
I want to get the inner html of the textarea as it is. If I try .html()
, it escapes all the tags and if I try .val()
, it decodes the escaped tags. You can see the behavior at http://jsfiddle.net/hnBte/
How can I get the pure content with Javascript and optionally, how can I make the textarea show the content as it is?
Thanks