Jump to content

Chg bgcolor of <div> w/ onmouseover


watagal

Recommended Posts

greetings,Trying to do:

<div id="divToc"    onmouseover="style.background-color='blue'"    onmouseout ="style.background-color='red'"    style="cursor:e-resize"></div>

yet nothing changes. I've tried: "style.bgcolor=...", "this.style.back..." and nothing yet.Can I do this to a <div> tag or is my syntax wrong (again)?TIA,WG

Link to comment
Share on other sites

Thanks aspnetguy. I know these are stupid questions, but I've seen "bgcolor", "backgroundColor", and "background-color" used for the same thing. I'm pulling my hair out.Is there rhyme or reason to all this? Better yet, is there a reference as to when to use what where?Thanks again - done venting.WG

Link to comment
Share on other sites

<head><script>[color="red"]document.bgColor="red";[/color]function change(){[color="green"]document.body.style.backgroundColor="green";[/color]}</script><style>[color="purple"]body{background-color:purple;}[/color]</style></head><body onload="change()"></body>

document.bgColor="red"; This is the pure javascript waybackground-color:purple; This is the css waydocument.body.style.backgroundColor="green"; This is the dhtml way (note that to the letter c in color is uppercase)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...