title: How to encode ampersand in URL with jQuery
body: <p>I have some URLs being dynamically output onto a div which contain an <code>&amp;</code> like this:</p>
  
  <pre><code>&lt;div id="box"&gt;
      &lt;a href="http://domain.com/index.html&amp;location=1"&gt;First URL&lt;/a&gt; 
      &lt;a href="http://domain.com/index.html&amp;location=2"&gt;Second URL&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Is there a way - using jQuery - for every instance of <code>&amp;</code> to be converted into the HTML entity equivalent instead, so that the output becomes this?</p>
  
  <pre><code>&lt;div id="box"&gt;
      &lt;a href="http://domain.com/index.html&amp;amp;location=1"&gt;First URL&lt;/a&gt; 
      &lt;a href="http://domain.com/index.html&amp;amp;location=2"&gt;Second URL&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>