HTML text in a textarea

HTML text in a textarea

Hi

I have some HTML in a textarea in my document:

<textarea id="html_out"><p>123</p></textarea>

After grabbing it and manipulating it as a var, I set it as the content of the textarea, effectively something like:

$('textarea#html_out').val('<p>ABC</p>');

What I want to do is wrap the textarea in a div:

$('textarea#html_out').wrap('<div></div>');

and then remove the textarea tags:

$('textarea#html_out').contents().unwrap();

and for the contents of the div to display as normal HTML, so I'd just see ABC as it's in a div.

I tried the above, and it just returns <p>123</p> (I can still see the tags as if they were in the text area.

Please could you let me know what I am doing wrong.

Thanks in advance!