ali
ali

Reputation: 11045

Replace <br> by \n in a textarea doesn't work in IE9

My problem is simple. I am trying to replace all the <br/> characters from a string by \n and display all the resulted string in a <textarea> element. CODE:

textarea.innerHTML = s.innerHTML.replace(/(\r\n|[\r\n])/g, '').replace(/<br[\s\/]?>/gi, '\n');

Inside the textarea, I should see separated lines by "\n". It works in any browsers, including IE6, but not in IE9. What is wrong? Thanks!

Upvotes: 0

Views: 1244

Answers (1)

Marat Tanalin
Marat Tanalin

Reputation: 14123

Try to use value property of textarea, not innerHTML.

Upvotes: 6

Related Questions