繁体   English   中英

我可以从jquery removeClass模拟回调函数吗?

[英]Can I emulate a callback function from jquery removeClass?

我正在尝试连续执行这些removeClass调用。 似乎没有使用removeClass的回调函数,所以有另一种方法来模拟这个吗?

  $("#card1").removeClass('flip');

  //wait for card1 flip to finish and then flip 2
  $("#card2").removeClass('flip');

  //wait for card2 flip to finish and then flip 3
  $("#card3").removeClass('flip');

看来你正在使用CSS3过渡来做这件事。 最简单的方法是手动设置延迟:

$("#card1").removeClass('flip');

setTimeout(function(){
   //wait for card1 flip to finish and then flip 2
   $("#card2").removeClass('flip');
}, 500);

setTimeout(function(){
   //wait for card2 flip to finish and then flip 3
   $("#card3").removeClass('flip');
}, 1000);

没有内置的jQuery方法来检查css转换是否完整。

Old Tread但Goolge现在是他;-)

jQueries UI有一个removeClass的扩展函数。

<div class="big-blue"></div>
$( "div" ).click(function() {
  $( this ).removeClass( "big-blue", 1000, "easeInBack", function(){
      // do fancy stuff after animation is completed
  });
});

jQuery-UI Doc: http//api.jqueryui.com/removeclass/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM