开发者

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")
          开发者_JAVA技巧 $("#el").animate({
             opacity: 1
           }, 
           800)
       });
     });
});


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜