admin管理员组

文章数量:1316376

I have a div whose innerHTML i want to put it in textarea, the problem is that the div content is with html tags and when i place that in textarea it does not show the executed html code but it shows text with html tags. I want the executed html code in the textarea, how can I achieve this? I have searched all through the net but not able to find it. Any kind of help will be highly appreciated

Thank you

I have a div whose innerHTML i want to put it in textarea, the problem is that the div content is with html tags and when i place that in textarea it does not show the executed html code but it shows text with html tags. I want the executed html code in the textarea, how can I achieve this? I have searched all through the net but not able to find it. Any kind of help will be highly appreciated

Thank you

Share Improve this question asked May 11, 2012 at 12:42 Eric IlaviaEric Ilavia 1013 silver badges9 bronze badges 7
  • Your question is not very clear. What do you want to see in the text area? – Jivings Commented May 11, 2012 at 12:43
  • Could you replace the textarea with a div? Why are you using a textarea element? – Fabrizio Calderan Commented May 11, 2012 at 12:43
  • @Jivings I think he wants to see the text rendered in the textarea as it would have been rendered in the div. – Simone Commented May 11, 2012 at 12:46
  • 1 You need to use some WYSIWYG Editor, TinyMCE for example tinymce. – antyrat Commented May 11, 2012 at 12:47
  • textarea is for text only. you cannot put any html tags in it. if you do need any maekup, just use a simple div. – Sagiv Ofek Commented May 11, 2012 at 12:47
 |  Show 2 more ments

1 Answer 1

Reset to default 8

Instead of textarea you can use div with contenteditable attribute:

<div contenteditable="true">
  This text can be edited by the user.
</div>

本文标签: javascriptPut html code in textareaStack Overflow