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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744649407a4585810.html
评论列表(0条)