<body> <div class="text"> <p> 距离我的生日还有: <span id="time1" class="otime"></span> </p > </div> <script src="js/jquery-1.11.3.js"></script> <script> var time = { starTime: 0, endTime: 0, timer: null, WAIT: 1000, init: function () { var starTime = new Date(); var endTime = new Date("2018/7/12 00:00:00"); var count = (endTime.getTime() - starTime.getTime()) / 1000; //得到的是毫秒数 var day = parseInt(count/(24*60*60)); var hours = parseInt(count/(60*60)%24); var minutes = parseInt(count/60%60); var seconds = parseInt(count%60); var html = $("#time1").html(` ${day}天${hours}小时${minutes}分${seconds}秒 `); // console.log(html); } }; $(function(){ time.init(); setInterval('time.init()', 1000); }); // time.init(); </script> </body>
jq 处理定时器
最新推荐文章于 2024-09-09 09:20:08 发布