topical media & game development

talk show tell print

#javascript-code-01-type.js / js



  // Locate the <div> that we want to hover over
  var div = document.getElementsByTagName(“div”)[0];
  
  // Bind a single function to both the mouseover and mouseout events
  div.onmouseover = div.onmouseout = function(e){
      // Normalize the Event object
      e = e || window.event;
  
      // Toggle the background color of the <div>, depending on the
      // type of mouse event that occurred
      this.style.background = e.type == “mouseover” ? “#EEE” : “#FFF”;
  };
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.