首页 > 代码库 > jQuery 倒计时
jQuery 倒计时
function getSec(){
//获取名称为remindataSec的ul
obj = document.getElementsByName("remindataSec");
for(i=0;i<obj.length;i++){
//循环得到每个毫秒数
var intDiff = $("#remindataTime"+i+"").text();
var id = "reminTime"+i;
//得到毫秒数和li标签的id
timer(intDiff,id);
}
}
//倒计时类型 为 0:00:00 小时:分钟:秒数
function timer(intDiff,id){
window.setInterval(function(){
var hour=0,
minute=0,
second=0;//时间默认值
if(intDiff > 0){
hour = Math.floor(intDiff/3600);
minute = Math.floor((intDiff-(hour*3600))/60);
second = Math.floor(intDiff-(hour*3600)-(minute*60));
}
if (minute <= 9) minute = ‘0‘ + minute;
if (second <= 9) second = ‘0‘ + second;
var daojishi= hour+":"+minute+":"+second;
if(intDiff<=600){
$(‘#‘+id+‘‘).css("color","red");
}
if(intDiff<=0){
searchMemo();
}
$(‘#‘+id+‘‘).text(daojishi+" 以后");
intDiff--;
}, 1000);
}
本文出自 “phpAjax请求” 博客,请务必保留此出处http://15129824665.blog.51cto.com/10510385/1875425
jQuery 倒计时