Add delay to mouseleave in jquery

后端 未结 4 1826
隐瞒了意图╮
隐瞒了意图╮ 2021-01-13 04:07

I\'m using this code in my site and I was wondering how I could add a delay to the mouseleave function

$target.mouseenter(function(e){
                var $t         


        
4条回答
  •  情话喂你
    2021-01-13 04:56

    You can use setTimeout() and an anonymous function for this:

    $target.mouseleave(function(e){
     var $tooltip=$("#"+this._tipid);
     setTimeout(function() { ddimgtooltip.hidebox($, $tooltip); }, 250);
    })
    

    This would delay it 250ms after leaving before it hides, you can just adjust that value as needed.

提交回复
热议问题