1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> <title>Jquery实现倒计时效果</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> var SysSecond; var InterValObj; $(document).ready(function() { SysSecond = parseInt($("#remainSeconds").html()); InterValObj = window.setInterval(SetRemainTime, 1000); }); function SetRemainTime() { if (SysSecond > 0) { SysSecond = SysSecond - 1; var second = Math.floor(SysSecond % 60); var minite = Math.floor((SysSecond / 60) % 60); var hour = Math.floor((SysSecond / 3600) % 24); var day = Math.floor((SysSecond / 3600) / 24); $("#remainTime").html(day + "天" + hour + "小时" + minite + "分" + second + "秒"); } else { window.clearInterval(InterValObj); } } </script> </head> <body> <div id="remainSeconds" style="display:none">360000</div> <div id="remainTime" style="font-size:20px;font-weight:800;color:#FF9900"></div> </body> </html>
|