views:

19

answers:

1

Hi,

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

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

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

draganHR
Thanks Dragan, it was the 2 line breaks that was in the html text code.
jamex