newHtml+="<span class='contentRowC' onmouseout='HiddeDetail("+articleId+")'onmouseover='GetArticleDetail("+articleId+")')>"+title +"</span></div></div>";
这里的newhtml为定义的变量,用来拼接字符串。如何使鼠标移过并且超过2秒的时候,才触发onmouseover事件,并且如果2秒之内,则取消这个事件?
这里的newhtml为定义的变量,用来拼接字符串。如何使鼠标移过并且超过2秒的时候,才触发onmouseover事件,并且如果2秒之内,则取消这个事件?
设一个全局变量.
onmouseover的时候一直对他增加.当此变量大于一个数后执行方法.
onmouseout的时候把变量置0;
var tipId;
var sTime;
function show()
{
sTime = 5;
tipId = window.setInterval("my()",1000);
}
function my()
{
if(sTime<0)
{
window.clearInterval(tipId);
document.getElementById("dvMsg").innerText="时间到...";
}
else
{
document.getElementById("dvTime").innerText=sTime;
sTime--;
}
}
</script>
</head>
<body>
<input type="button" onclick="show()" value="启动" />
<div style=" color:Red; font-size:200px"><div id="dvTime"></div></div>
<div id="dvMsg"><a href="http://www.baidu.com/">百度</a></div>
</body>
function begin()
{
timeout = setTimeout(aaa,"2000");
}
function cancel()
{
clearTimeout(timeout);
}
function aaa()
{}
<apan onmouseover="begin();" onmouseout="cancel();" ></span>