简体   繁体   English

无法在textarea内容中呈现HTML标记

[英]Not able to render HTML tags inside textarea content

I have a HTML file with textarea input element and the content is fetched from database which includes <br/> tags. 我有一个带有textarea输入元素的HTML文件,内容是从包含<br/>标签的数据库中提取的。

My JSON response is: 我的JSON响应是:
NDAs can be "mutual", meaning both parties are restricted in their use of the materials provided, or they can restrict the use of material by a single party. <br /> It is also possible for an employee to sign an NDA or NDA-like agreement with an employer.

On rendering it is not taking a new line and displaying <br/> as it is(taking as static content). 渲染是不采取新行,并显示<br/> ,因为它是(以静态内容)。 I used handlebars {{{content}}} but not helpful. 我使用了{{{content}}}把手,但没有帮助。

You simply can't enter HTML inside a textarea, you can only insert pure text. 您根本无法在textarea中输入HTML,您只能插入纯文本。

You may want to use an editable div ( <div contenteditable="true">...</div> ) 您可能想要使用可编辑的div( <div contenteditable="true">...</div>

Ref. 参考。 https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_Editable https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_Editable

如果您希望呈现HTML,则应使用contenteditable来执行此操作。

You can try replacing <br /> with /n . 您可以尝试用/n替换<br /> That should resolve your issue. 这应该可以解决您的问题。

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

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