I have put together a script where the main image loads once clicked on a thumbnail, however currently the image just swaps when clicking from one thumbnail image to another, I would like to have a smoother transition.
My code so far..
$('#thumbnails ul li').click(function(){
$('#main').fadeOut(500, function() {
$('#main').attr('src',$(this).find('img').attr('src').replace('small/', 'large/'));
}).fadeIn(500);
return false;
});
With this above code it fades out smoothly, but I can’t get the next image to fade back in when clicked. Do you know what this could be?
Thanks
You should put the
$(this).find('img')...outside of the context of thefadeOutmethod, in your codethisdoesn’t refer to your desired element (lielement), try this: