开发者

Run a method after the other method finished in JQUERY

开发者 https://www.devze.com 2023-03-22 09:19 出处:网络
I have a hide method.What I want is, after this hide method finishes, then the other method will run. How can I do that in Jquery ?

I have a hide method. What I want is, after this hide method finishes, then the other method will run. How can I do that in Jquery ?

For ex开发者_开发技巧ample

$('.panel').hide(400);

$('.panel2').fadeIn(400);

I want to run second line after the first one finished.

Thanks in advance,


hide method supports callback function parameter:

$('.panel').hide(400, function() { $('.panel2').fadeIn(400); });


$.when(function(){
    $('.panel').hide(400);
}).then(function(){
    $('.panel2').fadeIn(400);
});


$.when(function1()).then(function2());


As shown in the below link, the hide function can have a call back function

http://api.jquery.com/hide/

0

精彩评论

暂无评论...
验证码 换一张
取 消