<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#timediv{
width: 200px;
height: 200px;
}
</style>
</head>
<body>
<script type="text/javascript">
window.onload=function(){
document.getElementById("timeT").onclick=function(){
//一秒调用一次
//返回值是一个可以取消周期性调用的value
v = window.setInterval("Ttime()",1000)
}
document.getElementById("timeTT").onclick=function(){
//停止周期性调用
window.clearInterval(v)
}
}
function Ttime(){
var Time =new Date();
document.getElementById("timediv").innerHTML=Time.toLocaleString();
}
</script>
<input type="button" value="显示当前时钟" id="timeT" />
<input type="button" id="timeTT" value="停止" />
<div id="timediv">
</div>
</body>
</html>
JS动态显示时钟
最新推荐文章于 2022-04-04 12:19:50 发布