You have to make it fadeOut()
first, or hide it.
Try this :
$(".thumbs a").click(function(e) {
e.preventDefault();
$imgURL = $(this).attr("href");
$(".boat_listing .mainGallery")
.fadeOut(400, function() {
$(".boat_listing .mainGallery").attr('src',$imgURL);
})
.fadeIn(400);
});
It should fadeOut
the image, then change the src
when it's hidden, and then fadeIn
.
Here's a jsFiddle example.
Edit: you can find a more recent & better solution in Sandeep Pal's anwser
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…