Why does not work, when transferring the line?

var _wnd_content = ' <div id="abc"> text </div> '; 
  • one
    Should it? - karmadro4
  • If Google sends here for such questions, then I do so \ n \ - bypassing

1 answer 1

Because the syntax does not allow this.


 var _wnd_content = '\ <div id="abc"> \ text \ </div>'; 

Using an array:

 var _wnd_content = [ '<div id="abc">', ' text', '</div>' ].join("\n"); 

As usually do template engines:

 <script type="text/x-my-template" id="template_abc"> <div id="abc"> text </div> </script> var _wnd_content = $("#template_abc").html(); 

Using E4X (there will be a tree, not a string; and this does not work, at least in IE):

 var _wnd_content = <div id="abc">text</div>; 

ECMAScript 6 (this is how it will be in the bright future):

 var _wnd_content = ` <div id="abc"> text </div> `;