[英]Can I emulate a callback function from jquery removeClass?
I'm trying to execute these removeClass calls in succession. 我正在尝试连续执行这些removeClass调用。 There doesn't seem to be a call back function using removeClass so is there another way to emulate this? 似乎没有使用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');
It seems that you're using CSS3 transition for doing this. 看来你正在使用CSS3过渡来做这件事。 The easiest way to do this is to set delay manually: 最简单的方法是手动设置延迟:
$("#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);
There's no built in jQuery method to check that css transition is complete. 没有内置的jQuery方法来检查css转换是否完整。
Old Tread but Goolge now him ;-) Old Tread但Goolge现在是他;-)
jQueries UI has a extend Function for removeClass. 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/ jQuery-UI Doc: http : //api.jqueryui.com/removeclass/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.