首页 > Web开发 > 详细

jQuery – 鼠标经过(hover)事件的延时处理

时间:2017-02-28 13:39:23      阅读:198      评论:0      收藏:0      [点我收藏+]
(function($){
    $.fn.hoverDelay = function(options){
        var defaults = {
            hoverDuring: 200,
            outDuring: 200,
            hoverEvent: function(){
                $.noop();
            },
            outEvent: function(){
                $.noop();    
            }
        };
        var sets = $.extend(defaults,options || {});
        var hoverTimer, outTimer;
        return $(this).each(function(){
            $(this).hover(function(){
                clearTimeout(outTimer);
                hoverTimer = setTimeout(sets.hoverEvent, sets.hoverDuring);
            },function(){
                clearTimeout(hoverTimer);
                outTimer = setTimeout(sets.outEvent, sets.outDuring);
            });    
        });
    }      
})(jQuery);

实现

$("#test").hoverDelay({
    hoverEvent: function(){
        alert("经过我!");
    }
});

  

jQuery – 鼠标经过(hover)事件的延时处理

原文:http://www.cnblogs.com/qianxinxu/p/6478249.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!