title: JavaScript : Uncaught TypeError: Cannot set property 'href' of null
body: <p>While changing the href through javascript getting this error.Not able to change the href through javascript</p>
  
  
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var element = document.querySelector('a[href="www.google.com"]');
      element.href = "http://stackoverflow.com";
    &lt;/script&gt;
  </code></pre>
  
  
  
  <pre><code>&lt;div id="footer"&gt;
      &lt;ul&gt;
        &lt;li&gt;
          &lt;a target="_blank" href="http://www.google.com"&gt;Google&lt;/a&gt; 
        &lt;/li&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  </code></pre>