基于JS实现限时抢购倒计时间表代码
程序员文章站
2023-11-14 10:12:40
废话不多说了,直接给大家贴代码了,具体代码如下所示:
废话不多说了,直接给大家贴代码了,具体代码如下所示:
<html> <head> <meta http-equiv="content-type" content="text/html; charset=gb2312" /> <title>限时抢购倒计时间表</title> <style type="text/css"> *{margin:0;padding:0;} #content{width:300px;margin:0 auto;padding:10px;background:#eee;border:1px solid #999;} #content p span{color:red;font:bold 20px arial;} #content p a{font:12px/23px '宋体';color:#888;} .div1{ display:none;} </style> <script language="javascript"> function fresh() { var endtime=new date("2110/11/06,12:20:12"); var nowtime = new date(); var leftsecond=parseint((endtime.gettime()-nowtime.gettime())/1000); d=parseint(leftsecond/3600/24); h=parseint((leftsecond/3600)%24); m=parseint((leftsecond/60)%60); s=parseint(leftsecond%60); // document.getelementbyid("times").innerhtml=__h+"小时"+__m+"分"+__s+"秒"; document.getelementbyid("times").innerhtml=h+"小时"+m+"分"+s+"秒"; if(leftsecond<=0){ document.getelementbyid("times").innerhtml="已结束"; clearinterval(sh); } } var sh; sh=setinterval(fresh,1000); </script> </head> <body> <div id="content"> <h1>限时抢购啦!</h1> <p>还剩<span id="times"></span></p> </div> </body> </html>
以上所述是小编给大家介绍的基于js实现限时抢购倒计时间表代码,希望对大家有所帮助