6

Possible Duplicate:
What's the cleanest way to write a multiline string in JavaScript?

How does one go onto a new line in writing jQuery code not the actual output of the code, for example:

$('#foo').append('<div id="bla"> '+\n+'
                  </div>');

Something like that.

Community
  • 1
  • 1
daryl
  • 14,307
  • 21
  • 67
  • 92
  • @Felix - Great? It didn't show in the any recommendations. – daryl Jun 05 '11 at 23:52
  • 4
    I don't think this is a duplicate per se, this asks about the output including the newline character specifically whereas the proposed duplicate asks about multiline strings. Two different questions with the same answer is all. – Greg Flynn Jun 07 '11 at 01:29

1 Answers1

17
$('#foo').append('<div id="bla"> \
                 </div>');

The slash (\) escapes the newline, allowing the string to span multiple lines

Greg Flynn
  • 1,694
  • 2
  • 14
  • 15