jeffreynolte
jeffreynolte

Reputation: 3779

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)
       });
     });
});

Upvotes: 3

Views: 205

Answers (2)

Dr.Molle
Dr.Molle

Reputation: 117364

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.

Upvotes: 2

Josh Mein
Josh Mein

Reputation: 28665

It is probably an issue with how IE handles opacity. Quirksmode on opacity

Upvotes: 0

Related Questions