<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>RunJS</title>
<script>
var nn;
onload=function(){
setInterval(function(){
var n=new Date;
if(nn==null)
dd.innerHTML=n.getHours()+":"+n.getMinutes()+":"+n.getSeconds();
else
dd.innerHTML=nn+":"+n.getMinutes()+":"+n.getSeconds();
});
}
var add=function(){
var n=new Date;
if(null==nn)
nn=n.getHours()+1;
else
nn++;
}
var sub=function(){
var n=new Date;
if(null==nn)
nn=n.getHours()-1;
else
nn--;
}
var orial=function(){
var n=new Date;
nn=n.getHours();
}
</script>
</head>
<body>
<div id="dd">
</div>
<input type="button" value="+1" onclick="add()" />
<input type="button" value="-1" onclick="sub()"/>
<input type="button" value="恢复" onclick="orial()"/>
</body>
</html>
温馨提示:答案为网友推荐,仅供参考