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);
}?
轉載于:https://blog.51cto.com/15129824665/1875425