我已经写了一个jQuery CLICK事件,在这种情况下有两个代码会在点击事件后执行,但我想先完成第一个代码执行,然后完成后开始执行第二个代码。但是现在它们都在CLICK事件触发的同时执行。我想在完成另一个代码后执行一个代码
第一个代码是关于slideUp的,所以我想先完成slideUp然后开始执行第二个代码。这里是Fiddle
我在这里附上了代码和图片,请检查并帮助我,如果可以的话。
$(".team-item-area").on('click', function(){
$(this).siblings().find('.team-item-right-para').slideUp();
$(this).find(".team-item-right-para").slideToggle(function(){
var check = $(this).is(":visible");
if(check == true)
{
$(this).parents('.team-item-area').siblings().find('img').hide();
$(this).parents('.team-item-area').find("img").fadeIn();
} else {
$(this).parents('.team-item-area').find("img").show();
$(this).parents('.team-item-area').siblings().find('img').fadeIn();
}
});
})[enter image description here][1]
[RTFM](http://api.jquery.com/slideup/#slideUp-duration-complete)。 'slideUp()'接受'onComplete'回调参数。 – BenM
[jQuery - 等到SlideUp()结束的可能的重复](https://stackoverflow.com/questions/1084392/jquery-wait-till-end-of-slideup) – ednincer