<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
<script>
//开启定时器,每隔一秒钟,读取当前的时间,更新到body的文本中
setInterval(() => {
let now=new Date().toLocaleTimeString();
console.log(now);
//DOM:文本对象模型,浏览器会把html先转化成对象类型,再把对象显示到页面上
//转化出来的对象就是window的document对象
document.body.innerText=now;
}, 1000);
</script>
</html>