I'm writing html string in JS with this style:
var html = '\
<div id="parent">\
<div id="firstChild"></div>\
<div id="secondChild"></div>\
</div>\
';
However, these backslashes creates unexpected whitespaces which cause JS generate unexpected text nodes. How can I remove these whitespaces (with regex may be) ?
\n\instead of\)\) without the escape character? if you want a new line, you can do thisstring = "hello\nworld", which will output as "hello (new line) world". In this way, it can store the new line command in the js without altering the results, but you have to use double quotes for this"\n"and not'\n'. however, it's not neccessory to add new line sign in js since it is stored already when you make a new line in your editor