Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
13
rated 0 times [  19] [ 6]  / answers: 1 / hits: 7084  / 11 Years ago, mon, december 9, 2013, 12:00:00

I'm trying to run a function on the selector that addClass was just ran on after addClass is completed.



This way made sense to me, but it doesn't seem to be working:



$('.focused').addClass('fadeOutDown', function(){ $(this).remove(); });



How can I run a function after I've ran the addClass function on the same selector?



Chaining runs it at the same time and I haven't tried a set-timeout, but that seem inefficient.


More From » jquery

 Answers
3

Try to do this way :



 $('.focused').addClass('fadeOutDown');

setTimeout(function() {
$('.focused').remove();
}, 2000);

// make sure you provide appropriate time i.e after you get the effect

[#49716] Saturday, December 7, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aliah

Total Points: 118
Total Questions: 132
Total Answers: 94

Location: Tajikistan
Member since Fri, Sep 11, 2020
4 Years ago
;