Q:

How to parse Html formatted element

var div = document.getElementById('test');
var str = '<p>Just some <span>text</span> here</p>';
var temp = document.createElement('div');

temp.innerHTML = str;
while (temp.firstChild) {
    div.appendChild(temp.firstChild);
}

string is defined in one line I required in formatted style like below
var str = '<p>
             Just some
             <span>text</span>
              here
           </p>';

how to pass this string or html content to javscript.. it will be easy to modify..I too lone content to add so asking. 

A:

For multiline strings, add \ at the end of line.
var str = '<p>\
             Just some\
             <span>text</span>\
              here\
           </p>';

Blog

