title: Alt attribute encoding with JavaScript
body: <p>Html entities <a href="https://stackoverflow.com/questions/1165635/does-the-img-tags-alt-attribute-require-encoding">must be encoded</a> in alt attribute of an image in HTML page. So</p>
  
  <pre><code>&lt;img id="formula" alt="A &amp;rarr; B" src="formula.png" /&gt;
  </code></pre>
  
  <p>will work well.</p>
  
  <p>On the other hand, the same JavaScript code will not work</p>
  
  <pre><code>document.getElementById('formula').alt = 'A &amp;rarr; B';
  </code></pre>
  
  <p>and will produce <em>A &amp;rarr; B</em> instead of <em>A &rarr; B</em>.</p>
  
  <p>How to do it through JavaScript, when it is not possible to put the special (unencoded) characters in the source code?</p>