How can I fade out a div using jQuery?

前端 未结 7 1960
孤街浪徒
孤街浪徒 2020-12-05 09:46

Is there any way to fadeout a div after 5 Seconds without using a setTimeOut function?

7条回答
  •  萌比男神i
    2020-12-05 10:08

    // 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.

提交回复
热议问题