Jump to content

Dynamic background change on DIV


afish674

Recommended Posts

Hi all, I am trying to write a simple script to change the background colour of a div when a user hovers their mouse over the div, and then change it back when they move away. My code is as follows:

var contentBox=getElementById("mainContent");var footerDiv=getElementById("footer");contentBox.onmouseover= function(){contentBox.style.backgroundColor="#fff";};contentBox.onmouseout= function(){contentBox.style.backgroundColor="#09C";};

I get an error in firefox saying that "getElementById is not defined" but it is? I don't understand. I've checked this against the code in the book i'm using and its the same (apart from my div names being different.) Could someone please point out what is wrong? Many thanks, Anthony

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...