jquery延时处理

89203856 2014-09-26

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


     	
           function kbn_tag_delay (name1, name2) {
        		$(''+name2).hoverDelay({
			            hoverEvent: function(){
			               $(''+name2).css('display','none');     
			               $(''+name1).slideDown('slow');  
			               
			            } 
			     });
				 
				$(''+name1).mouseleave(function(){
					$(''+name1).css('display','none');//.siblings().css('display','block');
				//	$(''+name2).slideDown('slow');
					$(''+name2).css('display','block');
					//$('#tb2').css('display','block');
				}) ;
        	}
        	kbn_tag_delay('#tb1','#tb2');

相关推荐

ELEMENTS爱乐冬雨 / 0评论 2020-05-29