Mr.freelance :
I have this js :
var title = "firts title isn't working";
var html = "<input type='text' value='${title}'>";
I want to get this as result:
// "<input type='text' value='firts title isn't working'>"
but I get this !!!
// "<input type='text' value='firts title isn' t='' working=''>"
tevemadar :
If you do not need a mix of single and double quotes, you can use doubles in the template and then the single in the text will work:
var title = "firts title isn't working";
var html = `<input type="text" value="${title}">`;
document.body.innerHTML=html;
Otherwise HTML is HTML, and as @Barmar pointed out it has no escape characters...
... but, it has entities, and then you have both, regardless of the surrounding ones:
var title = ""firts" title isn't working";
var html = `<input type='text' value='${title}'>`;
document.body.innerHTML=html;
(What is firts
?)
And of course, you can do the replacement in code, so you can have "readable" strings, and .replace("\'","'");
them later.