Eric T
Eric T

Reputation: 1026

Jquery .when() and .then() not working?

I had try something with the below:

$.when($(smtg).fadeOut(300)).then($(smtg).fadeIn(300));

What's wrong with it while the document at http://api.jquery.com/jQuery.when/ Chrome console says Uncaught type error: has no method when

@@''

Upvotes: 2

Views: 704

Answers (2)

Michael Lorton
Michael Lorton

Reputation: 44376

Simplest possibility, you are using an older (than 1.5) version of jQuery.

Upvotes: 0

moe
moe

Reputation: 29704

Edit: You need jQuery 1.5+

OR simply do this:

$(smtg).fadeOut(300, function() {
    $(smtg).fadeIn(300);
});

This basically runs the fadeOut first, once the animation is done then it will run the callback function in our case the fadeIn

Upvotes: 4

Related Questions