Write a dynamic clock on a web page in HTML

Write a dynamic clock on a web page in HTML

Use HTML to write a dynamic web clock. The code is as follows:

<!DOCTYPE html>  
<html>  
    <head>  
        <meta charset="UTF-8">  
        <title>Clock Effects</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>Now is—"+hh+":"+mm+":"+ss+"</h1>"  
             
        }   
        //The setInterval() method can call a function or calculate an expression according to the specified period var mytime = setInterval("disptime()",1000);  
    </script>  
    <body onload="disptime()">  
        <div id="myclock"></div>  
    </body>  
</html>

Summarize

The above is what I introduced to you about writing a dynamic clock on a web page in HTML. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

<<:  JavaScript article will show you how to play with web forms

>>:  mysql method to recursively search for all child nodes of a menu node

Recommend

Let's talk about MySQL joint query in detail

Table of contents Union query 1. Query the ID and...

CentOS 8 custom directory installation nginx (tutorial details)

1. Install tools and libraries # PCRE is a Perl l...

Detailed introduction to deploying k8s cluster on centos7 system

Table of contents 1 Version and planning 1.1 Vers...

MySQL 8.0.14 installation and configuration method graphic tutorial (general)

MySQL service 8.0.14 installation (general), for ...

Should I use UTF-8 or GB2312 encoding when building a website?

Often when we open foreign websites, garbled char...

Detailed explanation of several error handling when Nginx fails to start

When using Nginx as a Web server, I encountered t...

JS achieves five-star praise case

This article shares the specific code of JS to ac...

Detailed explanation of Grid layout and Flex layout of display in CSS3

Gird layout has some similarities with Flex layou...

25 Ways and Tips to Increase Web Page Loading Speed

Introduction <br />Not everyone has access t...

Summary of four ways to loop through an array in JS

This article compares and summarizes four ways of...

Detailed explanation of gcc command usage under Linux system

Table of contents 1. Preprocessing 2. Compilation...

Packetdrill's concise user guide

1. Packetdrill compilation and installation Sourc...