HTML部分:
<!DOCTYPE html> <html> <head> <meta charset="gb2312"/> <title>高考倒计时</title> </head> <body> <p>高考倒计时:</p> <div id="box">11111</div> </body> </html>
CSS部分:
#box,p{ color:red; font-size:16px; width:300px; margin:0 auto; }
JS部分:
window.onload=function(){ var curtime=new Date();//当前时间 var endtime=new Date("2017,6,6");//结束时间 var lefttime=Math.ceil((endtime.getTime()-curtime.getTime())/(24*60*60*1000)); document.getElementById("box").innerHTML=lefttime; }
时间: 2024-10-26 19:45:18