I use the code below for the image gallery and would like to show the gif loader in the background when loading images, and then delete it after loading the image.
What is the best way to do this?
Note. I have already attached .fadeIn() and .fadeOut() with great luck (it seemed that both appeared at the same time.
$('ul a').click(function(e) { e.preventDefault(); var src = $(this).attr("href"); $('#main-img img').fadeOut(400, function() { $('<img/>').attr('src', src).load(function() { $('#main-img img').attr('src', this.src).fadeIn(400); }) }) });
source share