JQuery实现鼠标经过事件

通过http://www.zhangxinxu.com/wordpress/?p=906了解了一下鼠标经过事件的处理
(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(){
        //方法比如某个模块的显示调用$('').show();
    },
  outEvent: function(){
       //方法比如某个模块的隐藏调用$('').hide();
}
});
原文地址:https://www.cnblogs.com/wyhong/p/4791287.html