渡 //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<头>
<标题>标题>
<脚本 src="http://img.jb51.net/jslib/jquery/jquery-1.7.1.min.js" type="text/javascript">
function showTime(tuanid, time_distance) {
this.tuanid = tuanid;
//PHP时间是秒,JS时间是微秒
this.time_distance = time_distance * 1000;
}
showTime.prototype.setTimeShow = function () {
var timer = $("#lefttime_" this.tuanid);
var str_time;
var int_day, int_hour, int_month, int_second;
time_distance = this.time_distance;
this.time_distance = this.time_distance - 1000;
if (time_distance > 0) {
int_day = Math.floor(time_distance / 86400000);
时间距离 -= int_day * 86400000;
int_hour = Math.floor(time_distance / 3600000);
时间距离 -= int_hour * 3600000;
int_month = Math.floor(time_distance / 60000);
时间距离 -= int_分钟 * 60000;
int_second = Math.floor(time_distance / 1000);
if (int_hour int_hour = "0" int_hour;
if (int_month int_month = "0" int_month;
if (int_Second int_Second = "0" int_Second;
str_time = int_day "天" int_hour "小时" int_minute "分钟" int_second "秒";
timer.text(str_time);
var self = this;
setTimeout(function () { self.setTimeShow(); }, 1000); //D:正确
} else {
timer.text("团购结束");
返回;
}
}
脚本>
头>
<身体>
var st = new showTime(1,3);
//st.tuanid = 1;
//st.time_distance = 10000;
st.setTimeShow();
脚本>
var st = new showTime(2, 5);
//st.tuanid = 1;
//st.time_distance = 10000;
st.setTimeShow();
脚本>
身体>