I've been trying to follow the example from the sitepoint book on DHTML to change the href property of a link, but it doesn't work no matter what I try. Here's the code in the HTML file:
Here's the code in 'js/main.js' file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//
<link rel="stylesheet" href="style.css">
<a href="http://www.yahoo.com" id="changeMe">Yahoo </a>
Whenever I try to run this, the mozilla console gives this error:
var linkToChange = document.getElementById('changeMe')
What am I doing wrong??
Originally Posted by mozilla
Edit: Nevermind, I just fixed this problem by moving the line that calls up main.js at the end of all the html and it worked.