Page

[jquery]使用jquery制作最简单的日期实时更新功能

637Anson16-07-22


使用jquery制作最简单的日期时间实时跳动效果

完整代码如下


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
$(function(){

setInterval(function() {
   var time =(new Date()).toLocaleString();
   $('#now_time').text(time);
   },1000);

})

</script>
</head>
<body>
<span id="now_time"></span>
</body>
</html>


效果图:


时间会间隔一秒更新一次


blob.png



来自ansion博客

2016年7月22日