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

标签 javascript jquery if-statement visible animated

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

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

最佳答案

如果没有 if 语句,这样会更简洁一些。 working demo

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

关于javascript - jquery: this.not (':animated' ) && that.is (':visible' ) 不遵守规则,语法问题?只有几行代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4012218/

相关文章:

javascript - 调用获取返回 401

javascript - 如何使用 DataTables 过滤 OUT 特定行

javascript - 如何使用 javascript/jQuery 替换 onclick 操作(使用正则表达式)?

c++ - 在单个 IF 语句中测试多个 boolean 值

javascript - 选择 html select 下拉列表的动态创建选项

javascript - 带有引导框架的 extjs

javascript - 如何使用 jQuery 检查两个复选框是否都具有非空值

jquery - 单级联下拉(替代 ASP.net 中使用的)

c++ - 使用返回的 vector

Python if not == vs if !=