开发者

setTimeOut jquery problem

开发者 https://www.devze.com 2023-04-02 02:05 出处:网络
i would like to scroll the win开发者_如何学Cdow to the top, pause my animation for 1 second, and then use a fadeOut to erase the content, but this code doesn\'t work, do you know why?

i would like to scroll the win开发者_如何学Cdow to the top, pause my animation for 1 second, and then use a fadeOut to erase the content, but this code doesn't work, do you know why?

$('#link').bind('click', function(){
    preloading.show();

    $('html,body').animate({'scrollTop':0}, 300, function(){
        $('#myDiv').setTimeout(function(){
            $(this).empty()
                .append(conteneurBio).hide()
                .fadeIn('slow', function(){
                    preloading.hide();
                });
        }, 1000);
});


Wouldn't this work too?

$('html,body').animate({'scrollTop':0}, 300, function() {
        $('#myDiv')
             .empty()
             .hide()
             .append(conteneurBio)             
             .delay(1000)
             .fadeIn('slow', function() { preloading.hide(); }
    });


You're missing one set of closing });s:

$('#link').bind('click', function(){
    preloading.show();

    $('html,body').animate({'scrollTop':0}, 300, function()
    {
        setTimeout(function(){
            $('#myDiv').empty()
                .append(conteneurBio).hide()
                .fadeIn('slow', function(){
                    preloading.hide();
                });
        }, 1000);
    });
});


used something like: http://jsbeautifier.org/ it helps you find any missing brackets/braces in your javascript, especially when you don't have an editor that does the indentation for you.

Joseph posted before me with the correct answer though, you're missing a "});" at the end

0

精彩评论

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

关注公众号