jquery:this.not(’:animated’)&& that.is(’:visible’)不遵循规则,语法问题? 只有几行代码

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

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

在这里你有一个working demo

 $('#button').click(function(){ if( $('.wrapper:animated').length>0) { $(".wrapper").text("animating") ; } if( $('.wrapper:animated').length<1) { $(".wrapper").text("not animating") ; } }) 

没有if语句,这有点清晰。 工作演示

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