+1 vote
by
I use Jquery to insert my html code
$('div').append('<div>text<div>text2</div></div>');

But it is very difficult to read the code when there is a lot of it and it is shoved into a single line can it be somehow conveniently designed?
var test = /*
<div>
text
<div>
text2
</div>
</div>
*/;
$('div').append(test);

2 Answers

0 votes
by
 
Best answer
`<div>
text
<div>
text2
</div>
</div>`
0 votes
by
I usually do it this way:
var test = '<div>'+
'text'+
'<div>'+
'text2'+
'</div>'+
'</div>';

$('div').append(test);
An example on a more complex markup: 5f8459bc9d098138730381.png
P. S. I did not know that, but it turns out you can also use ` as a quote, that's probably the best option:
var test = `
<div>
text
<div>
text2
</div>
</div>
`;

$('div').append(test);
...