<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>网页时钟</title>
<style>
</style>
</head>
<body onload="start()">
<div id="clockDiv"></div>
<script>
function start(){
//每隔特定时间执行特定函数
//window可以省略
setInterval("showTime()",1000);
}
function showTime(){
var clockDiv = document.getElementById('clockDiv');
var nowTime = new Date;
var strNowTime = nowTime.toLocaleString();
clockDiv.innerHTML= strNowTime;
}
</script>
</body>
</html>
js 网页时钟
最新推荐文章于 2022-07-29 10:36:59 发布