Problems with Jquery image hover Hi. I'm trying to make a jquery image hover and it's working fine(I think) but I'm just puzzled as to how to achieve the effect I want. Greyed out thumbnail turns to colour on hover, clicking it changes the img.background then I want the thumbnail to remain in colour, as if "selected". Like I said, my code works but the problem is when you mouse out of the thumbnail, because of the first bit of code it switches back to the greyed out version. I can't figure out how to stop it or what other way I could be doing it in the first place.
$(".thumbnails img").hover(function(){
this.src = this.src.replace("-b","-a");
}, function() {
this.src = this.src.replace("-a","-b");
});
$(".thumbnails img").click(function(){
imgurl = this.src.replace("thumb-a", "bg")
$("img.background").attr({
src: imgurl
})
this.src = this.src.replace("-b","-a");
}); |