例子,js 高考倒计时代码。
复制代码 代码示例:
var timedate = new Date("June 7,2013");
var times = "2013年高考";
var now = new Date();
var date = timedate.getTime() - now.getTime();
var time = Math.floor(date / (1000 * 60 * 60 * 24)) + 1;
var s_time = String(time);
var s_time_leng = s_time.length;
if(s_time_leng == 2){
$("#time1").addClass("time" + s_time.substr(0,1));
$("#time2").addClass("time" + s_time.substr(1,1));
}
else if(s_time_leng == 1){
$("#time2").addClass("time" + s_time.substr(0,1));
}