【原创】jQuery单击事件和双击事件相互不影响实现
//鼠标单击和双击事件组件$.fn.onClick = function(onClick, onDblclick){ return this.each(function(){ var timer = null; var target = this; $(this).click(function(e){ clearTimeout(timer); timer = setTimeout(function(){ (onClick || $.noop).call(target, e); }, 400); }).dblclick(function(e) { clearTimeout(timer); (onDblclick || $.noop).call(target, e); }); }); };
?
?
?