2011-05-05 118 views
0

我有一个简单的jQuery制作的动画,但由于某种原因在IE8和以前的版本中不起作用。这里是我的代码:jquery不能在IE中工作

$(document).ready(function(){ 
       $('.circle.pink').animate({display: 'block'}, 800, function(){ 
        $(this).animate({right: 446}, 1200, 'easeOutExpo') 
       }); 

       $('.circle.green').animate({display: 'block'}, 2000, function(){ 
        $(this).animate({right: 20}, 800) 
       }); 

       $('.circle.blue').animate({display: 'block'}, 2800).animate({right: -100}, 800, function(){ 
        $(this).css('z-index', '4') 
       }).animate({right: 0}, 1000, 'easeOutExpo'); 
      }); 

这里的HTML:

<div class="circles-wrap"> 
     <div class="circle green"></div> 
     <div class="circle pink"> 
      <article class="intro"> 
       <span class="logo left"></span> 
       <p>Lorem ipsum....</p>         
      </article> 
     </div> 
     <div class="circle blue"></div> 
</div> 

和CSS:

.circle{ 
    width:514px; 
    height:514px; 
    display: block; 
} 

.circle.pink{ background:url('../images/c-pink.png'); position:absolute; right:0; z-index: 3;} 
.circle.blue{ background:url('../images/c-blue.png'); position:absolute; right:0; z-index: 2;} 
.circle.green{ background:url('../images/c-green.png'); position:absolute; right:0; z-index: 1;} 

任何想法,为什么它不工作?逗号似乎是在正确的地方。

由于提前,

莫罗

+0

你能提供与此相符的html吗? – anothershrubery 2011-05-05 10:32:51

回答

2

显示不是一个CSS属性可以在里面使用动画(),动画期待与数值属性。 也许这是抛出IE强制退出的错误。

+0

右键 - Firefox通常绕过像这样的属性错误,IE不行。您可以在动画触发后使用回调函数,然后您可以隐藏该元素,或者您可以在设置动画持续时间后将不透明度设置为0,您应该添加“,function(){$(element)”。 hide();}“...或添加不透明度动画。 – Atticus 2011-05-05 10:45:36

+0

是的,我没有想过。谢谢!我用数字值来代替另一个属性。 Btw IE浏览器仍然是有史以来最愚蠢的浏览器! :) – Mauro74 2011-05-05 10:46:37

+1

有史以来最愚蠢的处理你的坏编码?这就像走进餐厅和订购龙虾。他们告诉你菜单上没有龙虾,你抱怨。你去另外一家餐馆订购龙虾,他们会给你带来小牛肉,但是你很高兴地告诉你带来了什么东西,即使它不是你想要的东西。 – anothershrubery 2011-05-05 10:58:34