Is it possible to emulate a callback function from jquery removeClass?

I am trying to make these removeClass calls in a row. There doesn't seem to be a callback function using removeClass, so is there any other way to emulate this?

$("#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'); 
+6
source share
2 answers

You seem to be using CSS3 transition for this. The easiest way to do this is to set the 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 is no built-in jQuery method to verify that the css transition is complete.

+8
source

Old tread, but now gulge it ;-)

The jQueries user interface has an advanced feature for 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 Documentation: http://api.jqueryui.com/removeclass/

0
source

All Articles