Issue
console.log('Hello\nworld');
outputs:
Hello
world
If I write "Hello[ENTER_KEY]world" into a <textarea>
, then console.log($('textarea').html())
outputs:
Hello\nworld
How can I convert this so that \n
isn’t printed but shown as a line break in the console?
Solution
Try to use textarea value property as below:
function myFunction(){
console.log(document.getElementById('myTextArea').value);
}
<textarea id="myTextArea" onchange="myFunction()"></textarea>
Answered By – Sumit Sharma
Answer Checked By – David Goodson (AngularFixing Volunteer)