I have some simple image slider that I've made. I have list of small images, and whenever one of them is clicked, I replace source of target big image with clicked (+ some manipulation with src
to get bigger image from server).
Now I want on small image click to fadeout big image, and when new image is loaded to fade it in.
Tried with this code:
ul.find('img').click(function() {
$('#big_image')
.fadeOut()
.attr('src', this.src.replace('/small/', '/big/')) // Some other src
.load(function() {
$(this).fadeIn();
});
});
Problem with this is that when browser caches images, onclick image is immediately loaded, and then faded in and out, which looks a bit annoying.
This:
ul.find('img').click(function() {
$('#big_image')
.load(function() {
$(this).fadeIn();
})
.attr('src', this.src.replace('/small/', '/big/'))
.load(function() {
$(this).fadeIn();
});
});
does not fade at all.
Any idea?