Home > Web Front-end > JS Tutorial > JavaScript implements a simple clock

JavaScript implements a simple clock

高洛峰
Release: 2016-11-28 09:35:34
Original
881 people have browsed it

[html] 
<html>  
  
<head>  
  
<title>JS实现简单的时钟</title>  
<script>  
  
    function displayTime() {  
        document.getElementById("time").innerHTML = new Date().toTimeString();  
    }   
            
    setInterval(displayTime,1000);      // 每隔1秒钟调用displayTime函数  
</script>  
</head>  
  
<body>  
    <p id="time"></p>  
</body>  
  
</html>
Copy after login

JavaScript implements a simple clock

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