JavaScript动态显示时间

2021-03-18 18:24

阅读:534

标签:style   UNC   body   query   new   rgb   ack   tor   bsp   

body>
    div>div>

    script>
        var div = document.querySelector(div);
        retNowTime();
        setInterval(retNowTime, 1000);
        function retNowTime() {
            var date = new Date();
            var hours = date.getHours();
            hours = hours  10 ? 0 + hours : hours;
            var minutes = date.getMinutes();
            minutes = minutes  10 ? 0 + minutes : minutes;
            var seconds = date.getSeconds();
            seconds = seconds  10 ? 0 + seconds : seconds;
            div.innerHTML = hours + : + minutes + : + seconds;
        }
    script>
body>

 

JavaScript动态显示时间

标签:style   UNC   body   query   new   rgb   ack   tor   bsp   

原文地址:https://www.cnblogs.com/WP-WangPin/p/13796448.html


评论


亲,登录后才可以留言!