5

当我点击时#button,它仍然在做'do something',即使.wrapper是动画并且.wrapper span不可见。所以它不遵守规则。怎么了?

$('#button').click(function(){
  if(
    $('.wrapper').not(':animated') && $('.wrapper span').is(':visible')
  ) {
    //do something
  }
})
4

2 回答 2

6

如果没有 if 语句,这会更简洁一些。工作演示

$('#button').click(function(){ 
    $('.wrapper').filter(':animated').text("animating...");
    $('.wrapper').filter(':not(:animated)').text("not animating...");
}) 

​</p>

于 2012-06-22T18:48:20.230 回答
4

在这里你有一个working demo

$('#button').click(function(){
if(    $('.wrapper:animated').length>0)
{
 $(".wrapper").text("animating")   ;
}
  if(
    $('.wrapper:animated').length<1) {
 $(".wrapper").text("not animating")   ;
  }
})
于 2010-10-25T06:39:24.733 回答