G'day

I was having some trouble finding out why, whenever I call for
document.getElementById(id), it returns null (even if there is a valid
id-matching element). Consider something simple, like this:

The javascript runs as the page loads. At that point, the elements with the ids do not yet exist in the DOM tree (as they are still to be loaded). You'll need to delay the script until the page has loaded. Something like:

function init() {
  var toggle = document.getElementById('toggle');
  var onoff =  document.getElementById('onoff');
  toggle.onmouseover = function() {
    onoff.style.display = "block"
  }
  toggle.onmouseout = function() {
    onoff.style.display = "none"
  }
}
window.onload=init;


Regards
--
Bert Doorn, Better Web Design
http://www.betterwebdesign.com.au/
Fast-loading, user-friendly websites

******************************************************
The discussion list for  http://webstandardsgroup.org/

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
******************************************************

Reply via email to