<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p id="pDom"></p>
<div class="showTime"></div>
<script>
var t = null
t = setTimeout(time, 1000)
function time() {
clearTimeout(t)
dt = new Date()
var y = dt.getFullYear()
var mt = dt.getMonth()+1
var day = dt.getDate()
var h = dt.getHours()
var m = dt.getMinutes()
var s = dt.getSeconds()
document.querySelector('.showTime').innerHTML = '当前时间:' + y + '年' +mt + '月' + day +'--' + h+ '--'+h +'--'+m+'--'+s
t = setTimeout(time, 1000)
}
</script>
</body>
</html>
JS自动走的时钟【定时器】
最新推荐文章于 2024-08-06 23:12:50 发布