<!doctype html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="div1"></div>
<script>
function time() {
var date = new Date();
var hour = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var str = "现在的时间" + hour + "时" + minutes + "分" + seconds + "秒";
var div1 = document.getElementById("div1");
div1.innerHTML = str;
}
setInterval(time,1000);
</script>
</body>
</html>
网友评论