开发者

Javascript: Proper way to insert a newline in javascript [duplicate]

开发者 https://www.devze.com 2023-03-28 14:35 出处:网络
This question already has answers here: 开发者_StackOverflow社区Closed 11 years ago. Possible Duplicate:
This question already has answers here: 开发者_StackOverflow社区 Closed 11 years ago.

Possible Duplicate:

JavaScript string newline character?

I am aware that \n is the newline character but it does not work for IE. I have to use \r to get it to work for IE. Is there a javascript or JQuery function to insert a newline no matter the browser type?


If you are in an HTML element $("#myelement").append('<br />');

If you are in a textarea $("#mytextarea").append('\n');

It's a very obvious answer, tell you if it works or not.


Try using \r\n which is the windows newline. It should work in Linux and Unix as well though.

0

精彩评论

暂无评论...
验证码 换一张
取 消