jQuery - Function on toggleClass complete


/ Published in: jQuery
Save to your folder(s)

How can I do a function once a toggleClass has completed?

The .toggleClass method along with all other animation methods return a deferred object that you can access using .promise(). At that point, you can bind to it's done method.


Copy this code and paste it in your HTML
  1. $("#loader").toggleClass('fadeOut',600).promise().done(function(){
  2. alert('a');
  3. });

URL: http://stackoverflow.com/questions/10321393/jquery-function-on-toggleclass-complete

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.