首页 > 代码库 > 鼠标悬停(鼠标悬停一段时间后触发事件)一段时间后触发事件

鼠标悬停(鼠标悬停一段时间后触发事件)一段时间后触发事件

<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><script type="text/javascript">    var mytimer = null;       function beginEvent(){           //window.setTimeout("alert(‘Hello, world‘)", 1000);      mytimer = window.setTimeout("myfunc(‘123‘,‘456‘)", 3000);            }    function cancelEvent() {  clearTimeout(mytimer);        mytimer = -1;}function myfunc(t1,t2) {                alert(t1+" ,"+t2);        if (mytimer == -1) return;        var d = document.getElementById("div1");        d.innerText = new Date();        clearTimeout(mytimer);        mytimer = null;}</script></head><body>  <br/>  <br/>  <div id="div1" style="position: absolute; top: 100px; left: 100px; width: 100px; height: 100px; border: 1px solid black;" onm ouseover="beginEvent()" onm ouseout="cancelEvent()"></div></body></html>