Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
Replace \n from textarea with "invisible" line break in console

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?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Try to use textarea value property as below:

function myFunction(){
console.log(document.getElementById('myTextArea').value);
}
<textarea id="myTextArea" onchange="myFunction()"></textarea>

about 4 years ago · Juan Pablo Isaza Report

0

Try getting value instead of innerHTML

console.log($('textarea').val());
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!