0

I am trying to add some dynamic text which has multiple lines in textarea control, but it is not working in IE.

I followed the solution provided in this discussion:

New line in text area

Here is my JS code:

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

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

HTML

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

The above code works in Chrome but not in IE. I tried to add </br> instead of &#13;&#10; but that does not work in Chrome.

Is there any simple way to apply new line in textarea which works both in IE and Chrome?

Community
  • 1
  • 1
JGV
  • 5,037
  • 9
  • 50
  • 94

1 Answers1

1

Just use \n

'Hello, some text.\n'

and you should use val() not append()

epascarello
  • 204,599
  • 20
  • 195
  • 236