1

うまくいけば、それは迅速で簡単な質問になるでしょう.

簡単な関数を作成していますが、ページが読み込まれてから約 3 ~ 4 秒後にトリガーする必要があります。方法がわかりません。

これが私のスクリプトです

$(function () {
    var slideout = $('#slideout');
    slideout.animate({
        right: '-200px'
    }, 1000, function () {});
    $(".out").toggle(function () {
        $(this).addClass('in');
        slideout.animate({
            right: '0px'
        }, {
            queue: false,
             duration: 500
        });
    }, function () {
        $(this).removeClass('in');
        slideout.animate({
            right: '-200px'
        }, {
            queue: false,
            duration: 500
        });
    });
    $(".close").click(function () {
        $(this).removeClass('out');
        slideout.animate({
            right: '-200px'
        }, {
            queue: false,
            duration: 1000
        });
        slideout.fadeOut({
            duration: 1000
        });
    });
});

どんな助けでも大歓迎です。

4

2 に答える 2

15
$(document).ready(function(){
   setTimeout(function(){

         //YOUR CODE

   },4000);
});
于 2013-10-20T18:29:07.143 に答える
1
$(function () {
    var doInteresting = function () {
        var slideout = $('#slideout');
        slideout.animate({
            right: '-200px'
        }, 1000, function () {});
        $(".out").toggle(function () {
            $(this).addClass('in');
            slideout.animate({
                right: '0px'
            }, {
                queue: false,
                duration: 500
            });
        }, function () {
            $(this).removeClass('in');
            slideout.animate({
                right: '-200px'
            }, {
                queue: false,
                duration: 500
            });
        });
        $(".close").click(function () {
            $(this).removeClass('out');
            slideout.animate({
                right: '-200px'
            }, {
                queue: false,
                duration: 1000
            });
            slideout.fadeOut({
                duration: 1000
            });
        });
    }

    setTimeout(doInteresting, 3000);
});
于 2013-10-20T18:28:28.160 に答える