您的位置:首页 > 其它

textarea中的空格与换行

2014-12-10 16:41 204 查看
当在一个textarea标签中键入一个回车时,实际上会插入2个符号:\n\r
在javascript里, line breaks用\n表示
when you pull text into Javascript, it treats line breaks as the single "\n" value.


In Javascript, new lines are represented by a single "\n" character.

Textarea values might have the character combos "\n\r" in the text box, but once they are pulled into Javascript, "\n\r" becomes JUST "\n".

When replacing out new line characters, treat them as you would any other character. They are not special, they just have special notation.

Ask Ben: Javascript Replace And Multiple Lines / Line Breaks
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: