首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

哪位高手会 js倒计时,鼠标放下去时间停止,移除又开始

2012-11-08 
谁会 js倒计时,鼠标放上去时间停止,移除又开始如题,js差,求助[解决办法]div iddivTime onmouseoveri

谁会 js倒计时,鼠标放上去时间停止,移除又开始
如题,js差,求助

[解决办法]
<div id="divTime" onmouseover="ir=window.clearInterval(ir);" onmouseout="ir=setInterval("setTime()",1000);"></div>
-----------------
JS:
function setTime()
{
var div=document.getElementById('divTime');
div.innerHTML=new Date().getTime();
}
var ir=setInterval("setTime()",1000);



[解决办法]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
</head>
<body>
<div id="divTime" onmouseover="ir=window.clearInterval(ir);" onmouseout="ir=setInterval('setTime()',1000);"> </div> 
<script type="text/javascript">
function setTime() 

var div=document.getElementById('divTime'); 
div.innerHTML=new Date().getHours()+"-"+new Date().getMinutes()+"-"+new Date().getSeconds(); 

var ir=setInterval("setTime()",1000); 

</script>
</body>
</html>

[解决办法]

HTML code
<html> <head> <meta   http-equiv= "Content-Type "   content= "text/html;   charset=UTF-8 "> <script>var timer = 0;window.onload=function(){  timer = setInterval("abc()",1000)}function abc(){  var a = document.getElementById("demo");  var time = parseInt(a.innerHTML);  a.innerHTML = time-1;}function bcd(){  clearInterval(timer);}function efg(){  timer = setInterval("abc()",1)}</script></head> <body><div  id="demo" onmouseover="bcd()" onmouseout="efg()" style="border:1px solid black"> 1000</div> </body> </html>
[解决办法]
探讨
HTML code<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=UTF-8 ">
<script>
var timer = 0;
window.onload=function(){
timer = setInterval("abc()",1000)
}
function abc(){
var a = document.getElementById("demo");
var time = parseInt(a.innerHTML);
a.innerHTML = time-1;
}

function bcd(){
clearInterval(timer);
}
function efg(){
timer …

热点排行