title: Escaping double quotes in JavaScript onClick event handler
body: <p>The simple code block below can be served up in a static HTML page but results in a JavaScript error.  How should you escape the embedded double quote in the <code>onClick</code> handler (i.e. &quot;xyz)?  Note that the HTML is generated dynamically by pulling data from a database, the data of which is snippets of other HTML code that could have either single or double quotes.  It seems that adding a single backslash ahead of the double quote character doesn't do the trick.</p>
  <pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
      function parse(a, b, c) {
          alert(c);
      }
  &lt;/script&gt;
  
  &lt;a href=&quot;#x&quot; onclick=&quot;parse('#', false, '&lt;a href=\&quot;xyz'); return false&quot;&gt;Test&lt;/a&gt;
  </code></pre>