jamex jamex - 4 months ago 50
Javascript Question

how to assign a block of html code to a javascript variable

what is the syntax to store a block of html code to a javascript variable?

<div class='saved' >
<div >test.test</div> <div class='remove'>[Remove]</div></div>


I want to assign the above code to a variable 'test'

var test = "<div class='saved' >
<div >test.test</div> <div class='remove'>[Remove]</div></div>";


but it does not work, which are the correct syntax for assigning the code?

TIA

Answer
var test = "<div class='saved' >"+
"<div >test.test</div> <div class='remove'>[Remove]</div></div>";

You can add "\n" if you require line-break.