`
zengshaotao
  • 浏览: 810843 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

$.fn.hoverDelay

 
阅读更多

(function($){

    $.fn.hoverDelay = function(options){

        var defaults = {

            hoverDuring: 500,

            outDuring: 100,

            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);

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics