js完整倒计时代码分享
网络编程 2021-07-04 20:00www.168986.cn编程入门
这篇文章主要为大家详细介绍了js完整倒计时代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了js倒计时代码,供大家参考,具体内容如下
<html> <head> <title>倒计时测试</title> <script src="http://event.wushuangol./ShopClothes/Scripts/jquery-1.4.4.min.js" type="text/javascript"></script> <script language="JavaScript"> $(document).ready(function () { <!-- 时间必须启动 --> clockon(); }); function clockon() { var now = new Date(); var year = now.getFullYear(); //getFullYear getYear var month = now.getMonth(); var date = now.getDate(); var day = now.getDay(); var hour = now.getHours(); var minu = now.getMinutes(); var sec = now.getSeconds(); var week; month = month + 1; if (month < 10) month = "0" + month; if (date < 10) date = "0" + date; if (hour < 10) hour = "0" + hour; if (minu < 10) minu = "0" + minu; if (sec < 10) sec = "0" + sec; var arr_week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"); week = arr_week[day]; var time = ""; time = year + "年" + month + "月" + date + "日" + " " + hour + ":" + minu + ":" + sec + " " + week; $("#bgclock").html(time); var timer = setTimeout("clockon()", 200); } <!-- 隐藏脚本从旧的浏览器 var DifferHour = -1 var DifferMinute = -1 var DifferSecond = -1 var Tday1 = new Date("Feb 11, 2013 00:00:00") //倒计时时间-注意格式 var daysms = 24 60 60 1000 var hoursms = 60 60 1000 var Secondms = 60 1000 var microsecond = 1000 function clock() { var time = new Date() var hour = time.getHours() var minute = time.getMinutes() var second = time.getSeconds() var timevalue = ""+((hour > 12) ? hour-12:hour) timevalue +=((minute < 10) ? ":0":":")+minute timevalue +=((second < 10) ? ":0":":")+second timevalue +=((hour >12 ) ? " PM":" AM") var convertHour = DifferHour var convertMinute = DifferMinute var convertSecond = DifferSecond var Diffms = Tday1.getTime() - time.getTime() DifferHour = Math.floor(Diffms / daysms) Diffms -= DifferHour daysms DifferMinute = Math.floor(Diffms / hoursms) Diffms -= DifferMinute hoursms DifferSecond = Math.floor(Diffms / Secondms) Diffms -= DifferSecond Secondms var dSecs = Math.floor(Diffms / microsecond) if(convertHour != DifferHour) document.formnow.dd.value=DifferHour if(convertMinute != DifferMinute) document.formnow.hh.value=DifferMinute if(convertSecond != DifferSecond) document.formnow.mm.value=DifferSecond document.formnow.ss.value=dSecs document.formnow.ss.value=dSecs // document.formnow.Tnow.value= DifferHour DifferMinute + DifferSecond + dSecs setTimeout("clock()",1000) } // 隐藏--> </script> </head> <body onload="clock();return true" > <!--显示出内容--> <form name="formnow"> <input name="dd" type="text" style="border:0;" size=2> 天 <input name="hh" type="text" style="border:0;" size=2> 小时 <input name="mm" type="text" style="border:0;" size=2> 分 <input name="ss" type="text" style="border:0;" size=2> 秒 <span id="bgclock" style="float:right;padding-right:10px; padding-:2px;text="red""></span> </form> <!--倒计时完毕啦--> </body> </html>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持狼蚁SEO。
编程语言
- 如何快速学会编程 如何快速学会ug编程
- 免费学编程的app 推荐12个免费学编程的好网站
- 电脑怎么编程:电脑怎么编程网咯游戏菜单图标
- 如何写代码新手教学 如何写代码新手教学手机
- 基础编程入门教程视频 基础编程入门教程视频华
- 编程演示:编程演示浦丰投针过程
- 乐高编程加盟 乐高积木编程加盟
- 跟我学plc编程 plc编程自学入门视频教程
- ug编程成航林总 ug编程实战视频
- 孩子学编程的好处和坏处
- 初学者学编程该从哪里开始 新手学编程从哪里入
- 慢走丝编程 慢走丝编程难学吗
- 国内十强少儿编程机构 中国少儿编程机构十强有
- 成人计算机速成培训班 成人计算机速成培训班办
- 孩子学编程网上课程哪家好 儿童学编程比较好的
- 代码编程教学入门软件 代码编程教程