I have several lines of html that I need to keep in javascript to be invoked later, but the only way I have found is to store it in a variable , which is a bit annoying since everything is piled up and I cannot work well, what other way can I use ?
var set = ".<div id='01'>contenido</div>etc..."
You can put the html in the document with the tag
<template>
, the html inside<template>
is not rendered, then when you need it you can extract that html with javascript and manipulate it.Another way, if you're using a recent version of JS, would be to wrap the text in ``, so you can keep it formatted:
You can save several lines of code in a single variable by concatenating with JS
in your .html