开发者

jQuery: callback doesn't work right

I'm new to jQuery so forgive me (and cor开发者_如何学JAVArect me too please) if I say something wrong here.

I have this code and the callback is being executed right the moment the element is clicked, and not after the slideUp has finished:

$('.close-button').click(function(){
    $('.click-menu div').slideUp(3000, function() {
        $('.generic-box a, .generic-box p').css('z-index','1');
    });     
});

Am I missing something?

Any help would be greatly appreciated.

Thanks.


What's likely happening is that any already hidden <div> elements will execute the callback immediately, since their animations to hide are complete immediately, you can avoid this by only sliding up :visible elements, like this:

$('.close-button').click(function(){
    $('.click-menu div:visible').slideUp(3000, function() {
        $('.generic-box a, .generic-box p').css('z-index','1');
    });     
});


No the callback call once the animation is complete

you can use the jquery documentation it's realy helpful

http://api.jquery.com/slideUp/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜