前端 开发简易动态时钟

如何开发前端框架源码|web前端开发 php 视频教程下载|移动端html前端静态开发

html 代码

<!DOCTYPE html>
<html lang=”en”>
<head>
    <meta charset=”UTF-8″>
    <title>Document</title>
</head>
<body>
    <p id=’clock’></p>
    <script>
        function time() {
            var date = new Date();
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            if (m < 10) m = “0” + m;
            var d = date.getDate();
            if (d < 10) d = “0” + d;
            var h = date.getHours();
            if (h < 10) h = “0” + h;
            var i = date.getMinutes();
            if (i < 10) i = “0” + i;
            var s = date.getSeconds();
            if (s < 10) s = “0” + s;
            var mmm = y + “-” + m + “-” + d + ” ” + h + “:” + i + “:” + s;
            document.getElementById(“clock”).innerHTML = mmm;
        };
        setInterval(time, 1000);
    </script>
</body>
</html>

前端开发搭建服务器|前端开发好用的动画插件|搭建前端开发

» 本文来自:前端开发者 » 《前端 开发简易动态时钟》
» 本文链接地址:https://www.rokub.com/5194.html
» 您也可以订阅本站:https://www.rokub.com
赞(0)
64K

评论 抢沙发

评论前必须登录!