0

I have a div with attr("contentEditable",true). The problem if I enter text

111111111111

2222222222222222

33333333333333333

It simply take 1111111111111111112222222222222222222233333333333

I am taking div text using $.text()

Manish Kumar
  • 10,214
  • 25
  • 77
  • 147

2 Answers2

6

Because \n is not a newline character to web browsers. Web browsers ignore whitespace. If you want to display a new line you must add a <br> wherever you see a new line character.

John Conde
  • 217,595
  • 99
  • 455
  • 496
0

use <br> for new line \n is for source code

Anri
  • 1,706
  • 2
  • 17
  • 36