I am trying to create a hover over action which brings in a coloured image and also once the hover is removed it fades back to its original image.
Currently it fades out the image to nothing and then fades the new one in. This will then stay in place regardless of whether i hover off or no.
//Loop through the images and print them to the page
for (var i=0; i < totalBoxes; i++){
$.ajax({
url: "random.php?no=",
cache: false,
success: function(html) {
// following line I originally suggested, but let's make it better...
//$('#bg').append(html).fadeIn('slow');
// also note the fine difference between append and appendTo.
var $d = $(html).hide().appendTo('#bg').fadeIn('slow');
$('img', $d).hover(function() {
var largePath = $(this).attr("rel");
$(this).fadeOut("slow", function() {
$(this).attr({ src: largePath }).fadeIn("slow");
});
});
}
});
}
Update:
Please take a look at this link:
I am trying to get the images to cross fadein on rollover and out on fadeout...
Can anyone help, im so close and i have spent hours and hours trying to get my head around this...