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

前端之家收集整理的这篇文章主要介绍了javascript – jquery:this.not(‘:animated’)\u0026\u0026 that.is(‘:visible’)不遵循规则,语法问题?只有几行代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

当我点击#button时,它仍然在做’做某事’,即使.wrapper是动画,而.wrapper span是不可见的.所以它不遵守规则.怎么了?

  1. $('#button').click(function(){
  2. if(
  3. $('.wrapper').not(':animated') && $('.wrapper span').is(':visible')
  4. ) {
  5. //do something
  6. }
  7. })
最佳答案
在这里你有一个working demo

  1. $('#button').click(function(){
  2. if( $('.wrapper:animated').length>0)
  3. {
  4. $(".wrapper").text("animating") ;
  5. }
  6. if(
  7. $('.wrapper:animated').length<1) {
  8. $(".wrapper").text("not animating") ;
  9. }
  10. })

猜你在找的jQuery相关文章