jQuery获取系统时间并显示在HTML

今天在百度经验发现一句代码,极其简单的js获取时间直接显示。

首先新建一个容器

譬如一个<Span></Span>

然后上js:

<script>
        function showTime(){
            var curTime = new Date();
            $("#jstime").html(curTime.toLocaleTimeString());
            setTimeout("showTime()",1000)
        }
        $(function (){showTime()})

    </script>

jsTime就是我们的容器,如下图:

效果图如下:

下课!

猜你喜欢

转载自blog.csdn.net/u011723630/article/details/124620891