jquery实现停留半秒后再选择

jquery实现tab停留半秒后,选中菜单、切换tab下的内容:

var showHandler=null;
function init(){
	$("#tab_ul").find("li").each(function(index, ele){		
		var divId = "#nav"+index;
		$(ele).mouseover(function(){	
              //定时器,半秒后执行 showHandler = setTimeout(function(){ //实现操作 }, 500); }).mouseout(function(){
              //判断是否清空定时器 if(showHandler){clearTimeout(showHandler);} }); }); }

  鼠标在tab上停留,设置定时器半秒后事件才执行,如果不到半秒,清空定时器。

原文地址:https://www.cnblogs.com/zhaofeng555/p/3566299.html