delay JQuery effects

前端 未结 6 1711
别那么骄傲
别那么骄傲 2020-11-27 16:07

I want to fade out an element and all its child elements after a delay of a few seconds. but I haven\'t found a way to specify that an effect should start after a specified

6条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 16:29

    I use this pause plugin I just wrote

    $.fn.pause = function(duration) {
        $(this).animate({ dummy: 1 }, duration);
        return this;
    };
    

    Call it like this :

    $("#mainImage").pause(5000).fadeOut();
    

    Note: you don't need a callback.


    Edit: You should now use the jQuery 1.4. built in delay() method. I haven't checked but I assume its more 'clever' than my plugin.

提交回复
热议问题