最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Put html code in textarea - Stack Overflow

programmeradmin3浏览0评论

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>
发布评论

评论列表(0)

  1. 暂无评论