admin管理员组文章数量:1395237
I have a HTML file with textarea input element and the content is fetched from database which includes <br/>
tags.
My JSON response is:
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).
I used handlebars {{{content}}}
but not helpful.
I have a HTML file with textarea input element and the content is fetched from database which includes <br/>
tags.
My JSON response is:
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).
I used handlebars {{{content}}}
but not helpful.
-
You can't render html into a textarea, but you can force line breaks replacing
<br>
tags by\n
or\r
. To be sure, use a regex into replace function:yourString = yourString.replace(/\r?\n/g, '')
– kosmos Commented May 11, 2015 at 8:12 -
Did you try encoding your HTML? Like
<br>
bees<br>
? – Salman Arshad Commented May 11, 2015 at 8:52
3 Answers
Reset to default 2You simply can't enter HTML inside a textarea, you can only insert pure text.
You may want to use an editable div (<div contenteditable="true">...</div>
)
Ref. https://developer.mozilla/en-US/docs/Web/Guide/HTML/Content_Editable
If you want that your HTML will be rendered, you should use contenteditable to do so.
You can try replacing <br />
with /n
. That should resolve your issue.
本文标签: javascriptNot able to render HTML tags inside textarea contentStack Overflow
版权声明:本文标题:javascript - Not able to render HTML tags inside textarea content - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744649406a2617594.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论