jQuery鼠标经过(hover)事件的延时处理,具体JS代码如下:
- (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);
新闻热点
疑难解答
图片精选