[英]Preserving Linebreaks in textarea.value
I have to use textarea.value text but it does not preserve line breaks as input by the user. 我必须使用textarea.value文本,但它不能将换行符保留为用户输入的内容。 I don't want to use replace(/\\n\\r?/g, '<br />')
trick as it is useful only to render text as html. 我不想使用replace(/\\n\\r?/g, '<br />')
技巧,因为它仅用于将文本呈现为html有用。
Is there any other way to access textarea.value as it is? 是否有其他方法可以访问textarea.value?
在此示例http://jsfiddle.net/jfriend00/Gy7W3/中 ,在用户输入换行符的任何地方,文本区域都在.value
属性上返回换行符,因此它似乎已经完成了您想要的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.