title: Extract URL from HTML using Javascript and use it in a function
body: <p>I need to extract URL <code>link</code> from html.</p>
  
  <pre><code>&lt;a rel="nofollow" href="link" class="1"&gt;
  </code></pre>
  
  <p>There is only one such link on the whole page.</p>
  
  <p>Then I need to add use it as <code>a.href</code> in this function:</p>
  
  <pre><code>function changespan() {
      var spans = document.querySelectorAll('span.image');
      for (var i = spans.length; i--; ) {
          var a = document.createElement('a');
          a.href = "http://domain.com";
          spans[i].appendChild(a).appendChild(a.previousSibling);
      }
  }
  </code></pre>