您的位置:首页技术文章
文章详情页

JavaScript怎么实现的商品抢购倒计时

【字号: 日期:2023-11-30 09:31:51浏览:6作者:猪猪

JavaScript怎么实现的商品抢购倒计时?JavaScript实现的商品抢购倒计时功能。分享给大家供大家参考,具体如下:

<html> <head> <meta charset="utf-8"> <title>JS抢购倒计时</title> </head> <body> <span id="times" > <SCRIPT LANGUAGE="JavaScript"> function _fresh() { var endtime=new Date("2017/4/23,19:33: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); var c=new Date(); var q=((c.getMilliseconds())%10); document.getElementById("times").innerHTML=__d+"天 "+__h+"小时"+__m+"分"+__s+"."+q+"秒"; if(leftsecond<=0){ document.getElementById("times").innerHTML="抢购已结束"; clearInterval(sh); } } _fresh() var sh; sh=setInterval(_fresh,100); </SCRIPT> </span> </body> </html>

运行效果图如下:

JavaScript怎么实现的商品抢购倒计时

JavaScript怎么实现的商品抢购倒计时
标签: JavaScript
相关文章: