简体   繁体   English

textarea中的新行在IE 9中不起作用

[英]New line in textarea is not working in IE 9

I am trying to add some dynamic text which has multiple lines in textarea control, but it is not working in IE. 我试图添加一些动态文本,该文本在textarea控件中具有多行,但在IE中不起作用。

I followed the solution provided in this discussion: 我遵循了此讨论中提供的解决方案:

New line in text area 文字区域中的新行

Here is my JS code: 这是我的JS代码:

 var requestText = 'Hello, some text. 
' +
                   'Details are 
' +
                   'id: ' + user.Id+ '
' +
                   'count: ' + user.Count;

$('#RequestContentTxtBox').append(requestText);

HTML 的HTML

<textarea class="form-control" id="RequestContentTxtBox" rows="6"></textarea> 

The above code works in Chrome but not in IE. 上面的代码在Chrome中有效,但在IE中无效。 I tried to add </br> instead of &#13;&#10; 我尝试添加</br>而不是&#13;&#10; but that does not work in Chrome. 但这不适用于Chrome。

Is there any simple way to apply new line in textarea which works both in IE and Chrome? 有没有简单的方法可以在textarea中应用新行,而该行在IE和Chrome中都可以使用?

Just use \\n 只需使用\\ n

'Hello, some text.\n'

and you should use val() not append() 你应该使用val()而不是append()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM