title: How do I escape a single quote ( ' ) in JavaScript?
body: <p><strong>UPDATE:</strong>
  I want to give an updated answer to this question. First, let me state if you're attempting to accomplish what I have below, I recommend that you manage events by <a href="https://developer.mozilla.org/en-US/docs/Talk:DOM/element.addEventListener" rel="noreferrer">adding event listeners</a> instead. I highly recommend that you utilize <a href="https://jquery.com/" rel="noreferrer">jQuery</a> for your project and use their syntax to <a href="http://api.jquery.com/on/" rel="noreferrer">manage event listeners</a> over using DOM.</p>
  
  <p><strong>QUESTION</strong></p>
  
  <p>Okay, I am basically doing this:</p>
  
  <pre><code>document.getElementById("something").innerHTML = "&lt;img src='something' onmouseover='change(\'ex1\')' /&gt;";
  </code></pre>
  
  <p>I don't want double quotes (") where I put the \'. I only want a single quote, so I am trying to not make it put a double when it is used. I am trying to reach this in the final outcome.</p>
  
  <pre><code>&lt;img src="something" onmouseover="change('ex1')" /&gt;
  </code></pre>
  
  <p>Escaping isn't working for me.</p>
  
  <p>My marked answer works fine, however, the cleaner (and more professional-looking way, IMO) is  <a href="https://stackoverflow.com/a/16134953/1754890">loganfsmyth's answer</a>.</p>