Home > Web Front-end > HTML Tutorial > HTML implements web page dynamic clock

HTML implements web page dynamic clock

不言
Release: 2018-06-09 16:44:20
Original
5868 people have browsed it

This article introduces you to the effect of writing a dynamic web page clock in HTML through example code. Friends who need it can refer to it.

Write a dynamic web page clock in HTML. The code is as follows:

<!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>
Copy after login

The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please Follow PHP Chinese website!

Related recommendations:

HTML5 page to implement messages and replies

How to use js to splice html strings

The above is the detailed content of HTML implements web page dynamic clock. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template