开发者

jquery: this.not (':animated') && that.is (':visible') not following the rules, syntax problem? only few lines of code

开发者 https://www.devze.com 2023-01-22 07:26 出处:网络
when i click on #button, it\'s stilling doing the \'do something\', even though .wrapper is animati开发者_运维技巧ng and .wrapper span is not visible. so it\'s not following the rules. what\'s wrong?

when i click on #button, it's stilling doing the 'do something', even though .wrapper is animati开发者_运维技巧ng and .wrapper span is not visible. so it's not following the rules. what's wrong?

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


This is a bit cleaner without the if statements. working demo

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


Here you have a working demo:

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

精彩评论

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