简体   繁体   English

将html代码放在textarea中

[英]Put html code in textarea

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. 我有一个div我的innerHTML我想把它放在textarea中,问题是div内容是用html标签,当我把它放在textarea中时它没有显示执行的html代码,但它显示带有html标签的文本。 I want the executed html code in the textarea, how can I achieve this? 我想在textarea中执行html代码,我该如何实现? I have searched all through the net but not able to find it. 我已经在网上搜索过但无法找到它。 Any kind of help will be highly appreciated 任何形式的帮助将受到高度赞赏

Thank you 谢谢

Instead of textarea you can use div with contenteditable attribute: 您可以使用具有contenteditable属性的div而不是textarea

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM