Add delay to mouseleave in jquery

后端 未结 4 1852
隐瞒了意图╮
隐瞒了意图╮ 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 05:14

    (function($){
       $.fn.lazybind = function(event, fn, timeout, abort){
            var timer = null;
            $(this).bind(event, function(){
                timer = setTimeout(fn, timeout);
            });
            if(abort == undefined){
                return;
            }
            $(this).bind(abort, function(){
                if(timer != null){
                    clearTimeout(timer);
                }
            });
        };
    })(jQuery);
    
    
    $('#tooltip').lazybind(
        'mouseout',
        function(){
            $('#tooltip').hide();
        },
        540,
        'mouseover');
    

    http://www.ideawu.com/blog/2011/05/jquery-delay-bind-event-handler-lazy-bind.html

提交回复
热议问题