日期:2014-05-16  浏览次数:20405 次

谁会 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 …