I have a js file where I need to construct some HTML the problem is it needs to be in a string to be parsed. Something like;
var myHTML="<a href='"#"' onclick='"alert("hello"); event.returnValue = false; return false;"'>"+childOrders+"</a>"
I have tried lots of combinations of quotes but just cannot get it to work.
Thanks for the help,
Chris
You can escape quotes within a string by putting a backslash in front of them, like so:
The above will result in the string
A string with "quotes" in it.EDIT: As for the quotes inside the onclick attribute, I would suggest using single quotes, so your code would look like this: