title: How can I add "href" attribute to a link dynamically using JavaScript?
body: <p>How can I add the <code>href</code> attribute to a link dynamically using JavaScript?</p>
  
  <p>I basically want to add a <code>href</code> attribute to <code>&lt;a&gt;&lt;/a&gt;</code> dynamically (i.e. when the user clicks on specific image in the website). </p>
  
  <p>So from:</p>
  
  <pre><code>&lt;a&gt;Link&lt;/a&gt;
  </code></pre>
  
  <p>I need to go to:</p>
  
  <pre><code>&lt;a href="somelink url"&gt;Link&lt;/a&gt;
  </code></pre>