I have an IMG tag with a grayscale image. I hooked up a Hover() event in order to change the \"src\" to a color image on hover, and back to grayscale on mouse-out.
Here are a couple solutions. Your code doesn't work because you are setting the source which changes the image immediately. It's probably easier just to load both images, overlay them with CSS and then fade the color one in out when the parent container is moused over. Alternatively you could cross fade them
css
.fader { display: inline-block; }
.fader img:last-child {
position: absolute;
top: 0;
left: 0;
display: none;
}
html
fade in on mouseover
http://jsfiddle.net/Xm2Be/3/
$('.fader').hover(function() {
$(this).find("img:last").fadeToggle();
});
cross fade
http://jsfiddle.net/Xm2Be/2/
$('.fader').hover(function() {
$(this).find("img").fadeToggle();
});