I want to put the below html code in my javascript function. I don\'t want to put it all next to each other. Is it possible to the code in the same way as how it is in html? Cod
You can kind of do this:
var myHtml = [
'firstline',
'second line',
'third line'].join("\n");
So pretty much you still need to break up the code some how.
An alternative (if the code is going to be large) would be to store in a HTML file and when you need, retrieve it quickly with $.get
and possibly cache it somewhere in a variable.
$.get('snippet.html', function(data) {
$('.result').html(data);
});
I think this is actually a pretty good idea as modifying that snippet will be much easier.