If mouse over for over 2 seconds then show else don't?

前端 未结 2 2080
孤街浪徒
孤街浪徒 2020-12-02 15:42

Here is a jQuery slide function I have applied to a div on hover in order to slide a button down.

It works fine except that now everytime someone moves in and out o

2条回答
  •  有刺的猬
    2020-12-02 16:17

    var time_id;
    
    $("#NewsStrip").hover(
    function () {
        if (time_id) {
            clearTimeout(time_id);
        } 
        time_id = setTimeout(function () {
            $("#SeeAllEvents").stop(true, true).slideDown('slow');
        }, 2000);
    }, function () {
        if (time_id) {
            clearTimeout(time_id);
        } 
        time_id = setTimeout(function () {
            $("#SeeAllEvents").stop(true, true).slideUp('slow');
        }, 2000);
    });
    

提交回复
热议问题