时间:2021-07-01 10:21:17 帮助过:30人阅读
用html写一个动态网页时钟,代码如下所示:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>时钟特效</title>
</head>
<script type="text/javascript">
function disptime(){
var today=new Date();
var hh=today.getHours();
var mm=today.getMinutes();
var ss = today.getSeconds();
document.getElementById("myclock").innerHTML="<h1>现在是—"+hh+":"+mm+":"+ss+"</h1>"
}
//setInterval()方法可以按照指定的周期调用函数或计算表达式
var mytime = setInterval("disptime()",1000);
</script>
<body onload="disptime()">
<p id="myclock"></p>
</body>
</html>
以上就是HTML制作网页动态时钟教程的详细内容,更多请关注Gxl网其它相关文章!