Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74325

JavaScript : Uncaught TypeError: Cannot set property 'href' of null

$
0
0

While changing the href through javascript getting this error.Not able to change the href through javascript

<script type="text/javascript">
    var element = document.querySelector('a[href="www.google.com"]');
    element.href = "http://stackoverflow.com";
  </script>
<div id="footer">
    <ul>
      <li>
        <a target="_blank" href="http://www.google.com">Google</a> 
      </li>
    </ul>
  </div>

Viewing all articles
Browse latest Browse all 74325


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>