title: how to encode single quote/apostrophe in jquery?
body: <p>here I am trying to encode single quote/apostrophe which i have to bind to an image as an <strong>alternate text</strong>.<br/>
  I am trying to encode it because while I have apostrophe or single quote in string as like 
  <strong>this is image's alternate text</strong> <br/>
  and I am binding it to image tag from jquery itself then after binding it shows alt text as <br/>
  <strong>alt="this is image"s alternate text"</strong><br/>
  where it's has to be displayed like<br/>
  <strong>alt="this is image's alternate text"</strong><br/>
  my code is as below.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var alternateText = "this is image's alternate text";
  var URL = "Image url"
  var r = "&lt;div&gt;&lt;a class='popup'&gt;&lt;img src='" + URL + "' class='img-responsive 'alt='" + alternateText + "&gt;&lt;/a&gt;&lt;/div&gt;";
  $("div#div1").html(r);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div id="div1"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>