开奖倒计时小钟html代码
- 提问者网友:蓝琪梦莎
- 2021-02-26 17:57
- 五星知识达人网友:琴狂剑也妄
- 2021-02-26 19:19
- 1楼网友:末日狂欢
- 2021-02-26 20:44
倒计时这种功能,用js比较好。
给你一个参考代码:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="www.w3.org/1999/xhtml"> <head> <title>实时倒计时</title> <meta http-equiv="content-type" content="text/html;charset=gb2312"> </head> <body> <!--单位:秒--> 剩余时间:<span id="endtime">10</span> <script type="text/javascript"> var cid = "endtime"; if(window.cid != null) { var itime = document.getelementbyid(cid).innertext; var account; remaintime(); } function remaintime() { var iday,ihour,iminute,isecond; var sday="",shour="",sminute="",ssecond="",stime=""; if (itime >= 0) { iday = parseint(itime/24/3600); if (iday > 0) { sday = iday + "天"; } ihour = parseint((itime/3600)%24); if (ihour > 0){ shour = ihour + "小时"; } iminute = parseint((itime/60)%60); if (iminute > 0){ sminute = iminute + "分钟"; } isecond = parseint(itime%60); if (isecond >= 0){ ssecond = isecond + "秒"; } if ((sday=="")&&(shour=="")){ stime="<span style='color:darkorange'>" + sminute+ssecond + "</font>"; } else { stime=sday+shour+sminute+ssecond; } if(itime==0){ cleartimeout(account); stime="<span style='color:green'>时间到了!</span>"; } else { account = settimeout("remaintime()",1000); } itime=itime-1; } else { stime="<span style='color:red'>倒计时结束!</span>"; } document.getelementbyid(cid).innerhtml = stime; } </script> </body> </html>