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
  • 9,824
  • 21
  • 74
  • 137

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
  • 212,985
  • 98
  • 444
  • 485
0

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

Anri
  • 1,656
  • 2
  • 16
  • 34