View Full Version : Change DIV BG Image On Hover

05-20-2005, 05:45 PM
I'm having trouble changing a DIV background image when it is hovered over - is there an easy way?!

05-20-2005, 06:27 PM
div {
background: #hex123 url(back.gif);

div:hover {
background-image: url(backhover.gif);

05-20-2005, 08:32 PM
Okay so ollie gave you the way that would work in any other browser but IE. You might want to use the javascript way to ensure that it will work in IE if of course javascript is enabled.

<div onmouseover="this.style.background='url(yourimage.jpg)';" omouseout="this.style.background='url(youroriginalimg.jpg)';"></div>

EDIT: Sorry I forgot the single quotes, that is why it wasn't working.

05-20-2005, 10:10 PM
Thanks, but why am I getting an error with -

<div id="startbutton" onmouseover="this.style.background=url(Start_Hover.JPG);" onmouseout="this.style.background=url(Start_Off.JPG);">

EDIT: No worries - working now!