[thelist] (JS) getElementById

Scott Brady evolt at scottbrady.net
Mon Jul 7 15:20:02 CDT 2003


---------- Original Message ----------------------------------
From: "Stephen Caudill" <SCaudill at municode.com>
>  Can someone tell me why this:
>
>document.getElementById("contact").style.color = '#ffcc00';
>
>is not working?  if you'd like to see the page it's in:


In your source code, you're calling "getElementById" at the top of the page, before the page has been constructed.

What that means is that your element "contact" doesn't exist yet.

You need to either call that script as an onload or put it at the bottom of the page.  I don't know if putting scripts at the bottom validates or not, so I'd do the onload option.

Scott
---------------------------
Scott Brady
http://www.scottbrady.net/
 
             


More information about the thelist mailing list