textarea中的空格与换行

当在一个textarea标签中键入一个回车时,实际上会插入2个符号:


在javascript里, line breaks用 表示
when you pull text into Javascript, it treats line breaks as the single " " value.
  1. In Javascript, new lines are represented by a single " " character.
  2. Textarea values might have the character combos " " in the text box, but once they are pulled into Javascript, " " becomes JUST " ".
  3. 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

原文地址:https://www.cnblogs.com/alexandra/p/4155822.html