0

If I have a variable named test and inside it I had html content like

var test = "<div class='testingbot'>
                <span>TITLE</span>
            <div>";

When I use the above it crashes the page, but if I do it all as one line it works

var test = "<div class='testingbot'><span>TITLE</span><div>";

How would I be able to print with line breaks?

Thanks

ngplayground
  • 20,365
  • 36
  • 94
  • 173
  • You could opt to use CoffeeScript, which just automatically lets you do this (among a million other awesome things) – Brad M Mar 21 '14 at 20:22

1 Answers1

3

Javascript doesn't do multi-line strings like that, you need to just concatenate them together.

var test = "<div class='testingbot'>" +
               "<span>TITLE</span>" +
           "<div>";
Tesserex
  • 17,166
  • 5
  • 66
  • 106