A jQuery related question – I have a little gallery style script working – a list of thumbnails and associated larger images switching on thumbnail click, like so:
$('#thumbs').delegate('img','click', function(){
$('#largeImage').attr('src',$(this).attr('src').replace('thumb','large'));
});
My question is: what’s the easiest way of making the image transitions fade between one another rather than a straight switch?
Many thanks in advance for your help.
You can
fadeOutthe image, thenfadeInin the callback after swapping thesrc:Live example using our gravatars | source
(Note that there’s no need to go through
attrforsrc; it’s reflected on the DOM element.)