There is so much confusion about escaping quotes in javascript and HTML, especially when they are mixed like this.
Straight off the bat, try to avoid this situation in the first place. HTML is for markup, Javascript is for behaviours. That said...
In Javascript, you escape quotes with a backslash. This is so that when javascript interprets the string it knows where it ends.
var name = O Reilly ;
In HTML, you use ampersands and a character code.
O"Reilly
Just remember that when you are writing code in your HTML, it s not being interpreted by javascript, it s being interpreted by the HTML parser. To a HTML parser, a backslash is just a regular character.
<a onclick="foo("bar");">
Now you see why I d recommend avoiding the situation in the first place. Here s the alternative:
<a id="myLink">
<script type="text/javascript">
document.getElementById( myLink ).onclick = function() {
foo( bar );
};
</script>