Possible Duplicate:
jQuery fade to new image
I have the following code to swap (preloaded) images on hover:
$(document).ready(function() {
$(".pf-item img").hover(
function(){this.src = this.src.replace(".jpg","-h.jpg");},
function(){this.src = this.src.replace("-h.jpg",".jpg");
});
var imgSwap = [];
$(".img-swap").each(function(){
imgUrl = this.src.replace(".jpg","-h.jpg");
imgSwap.push(imgUrl);
});
$(imgSwap).preload();
});
$.fn.preload = function() {
this.each(function(){
$('<img/>')[0].src = this;
});
}
It works really well, however I'd like to be able to fade between the images .jpg and -h.jpg.
Does anyone know how to do this/have a better way of approaching the issue? I have attempted lots of different fadeIn() approaches, but all seem to either not work, or work for a few hovers, then replace a blank image.