Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

issues with IE and jQuery load()

I have the following function which works fine in every browser but IE. When loading one image and then going back and clicking on the same <a> tag the image fades out but does not load back in. I am puzzled to why this works in other browsers but not in IE. Any and all insight greatly appreciated.

$('a').click(function({
  $("#el").animate({
       opacity: 0
     }, 800,
     function(){
       $("<img/>").attr('src', 'http://www.google.com/images/logos/ps_logo2.png').load(function(){
           $("#el img").attr('src', "http://www.google.com/images/logos/ps_logo2.png")
           $("#el").animate({
             opacity: 1
           }, 
           800)
       });
     });
});
like image 533
jeffreynolte Avatar asked Mar 23 '26 19:03

jeffreynolte


1 Answers

Assign the load-function before setting the src.

The image is in the cache after the first click, so it will be loaded immediately, the .load() comes to late.

like image 109
Dr.Molle Avatar answered Mar 25 '26 08:03

Dr.Molle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!