How to tell .hover() to wait?

后端 未结 9 1128
梦谈多话
梦谈多话 2020-11-29 17:36

I have a drop down menu. Now when it\'s slided down to multiple levels, I\'d like it to add wait time for like 2 secs, before it disappears, so the user can get back in, whe

9条回答
  •  悲&欢浪女
    2020-11-29 18:23

    I would like to add to Paolo Bergantino that you can do this without the data attribut:

    var timer;
    $('.icon').hover(function() {
        clearTimeout(timer);
        $('li.icon > ul').slideDown('fast');
    }, function() {
        timer = setTimeout(function() {
            $('li.icon > ul').slideUp('fast');
        }, 2000);
    });
    

提交回复
热议问题