When I'm building HTML in JavaScript I'm constantly escaping double quotes. E.g.
$(wrapper).append("<input type=\"text\" name=\"thingummy[" + id + "]\" data-id=\"" + data_id + "\" id=\"" + id + "_" + data_id + "\" /> <br>");
and, when there are many quotation marks, I'm constantly making mistakes over which quotes I've escaped. And I end up spending more time than I'd like fixing them.
Is there a better (quicker / safer / more legible) way of building HTML than the approach I'm using?
UPDATE
One rather important point I forgot to mention! I'm outputting this JavaScript using PHP. So, I have code like this:
echo '$(wrapper).append("<input type=\"text\" name=\"thingummy[" + id + "]\" data-id=\"" + data_id + "\" id=\"" + id + "_" + data_id + "\" /> <br>");';
which makes using single quotation marks a problem ('cos they end up breaking the PHP! Which is another problem I keep experiencing when I forget I'm in the middle of some PHP and use a single quotation mark as mentioned in a comment below).
$(wrapper).append('...'). You can also use the HTML quotes (") as well in a general case.