Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS remove an image and add a new image on mouse hover Re: remove an image and add a new image on mouse hover

#66780
evilhita666
Member

I would do it using jQuery, if you can have it available in your project… It would be something along the lines of:

Code:
$(“img”).hover(function(){
$(this).attr(“src”, “images/newImage.png”);
}, function(){
$(this).attr(“src”, “images/oldImage.png”);
};
});

Alternatively (and probably better depending on what you’re trying to achieve), you could use a <div> or <a> element with a background image, and use CSS sprites + jQuery to get those same results…