开发者

Javascript: Proper way to insert a newline in javascript [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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜