Home > Web Front-end > JS Tutorial > How to output time in html document/specified tag

How to output time in html document/specified tag

一个新手
Release: 2017-10-11 09:36:16
Original
2141 people have browsed it


<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <script>
            window.onload=function(){
             var a=new Date();            //向id为a的p中输出时间

              //document.getElementById("a").innerHTML=a;
              //向当前文档输出时间
               document.write(a);
            }        </script>
    </head>
    <body>
        <p id="a"></p>
    </body>
 </html>
Copy after login

The above is the detailed content of How to output time in html document/specified tag. 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