简体   繁体   中英

Preserving Linebreaks in textarea.value

I have to use textarea.value text but it does not preserve line breaks as input by the user. I don't want to use replace(/\\n\\r?/g, '<br />') trick as it is useful only to render text as html.

Is there any other way to access textarea.value as it is?

在此示例http://jsfiddle.net/jfriend00/Gy7W3/中 ,在用户输入换行符的任何地方,文本区域都在.value属性上返回换行符,因此它似乎已经完成了您想要的操作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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