I have a chunk of HTML which I'd like to add to a document at run time.
How do I embed the HTML within the JS file?
var p = document.createElement("div");
p.innerHTML = '<div> MY HTML
<some element> </some element>
<some element> </some element>
</div>'
The problem is that my HTML is multiline; how do I add the newline chars within a JS string?
From stackoverflow
-
See (answers to) http://stackoverflow.com/questions/805107/multiline-strings-in-javascript
-
you can use backslash character to ignore end of line in JavaScript strings.
http://www.componentart.com/BLOGS/jovan/archive/2007/10/17/multiline-strings-in-javascript.aspx
0 comments:
Post a Comment