$(document).ready(function(){
var blockIpIt =
setInterval(function(){
var day = $('#timer .TD').html(), hours = $('#timer .TH').html(), minutes = $('#timer .TI').html(), seconds = $('#timer .TS').html();
hours = hours < 1 ? '00' : hours;
minutes = minutes < 1 ? '00' : minutes;
seconds = seconds < 1 ? '00' : seconds;
if(seconds == '00'){
seconds = '59';
if(minutes == '00'){
minutes = '59';
if(hours == '00'){
if(day == '00'){
location.reload();
}
else{
day = (parseInt(day)); day = day < 10 ? '0' + day : day;
}
}
else{
hours = (parseInt(hours) - 1); hours = hours < 10 ? '0'+ hours : hours;
}
}
else{
minutes = (parseInt(minutes) - 1); minutes = minutes < 10 ? '0'+ minutes : minutes;
}
}
else{
seconds = (parseInt(seconds) - 1); seconds = seconds < 10 ? '0'+ seconds : seconds;
//minutes = 00;
//hours = 00;
}
$('#timer .TD').html(day);
$('#timer .TH').html(hours);
$('#timer .TI').html(minutes);
$('#timer .TS').html(seconds);
}, 1000);
});
// ajax отправка запроса
function update_time(){
$.ajax({
url: '/ajax/process.php?p=1',
type: 'post',
data: {'upd':1},
success: function(result) {
//alert(x); // для проверки отправляемого
//$('.results').html(result);
//setTimeout('location.replace("/account/dep")',2000);
}
});
}
Definition and Usage
The id attribute specifies a unique id for an HTML element (the value must be unique within the HTML document).
The id attribute is most used to point to a style in a style sheet, and by JavaScript (via the HTML DOM) to manipulate the element with the specific id.
$('.timer').each(function(){
$timer = $(this)
setInterval(function(){
let day = $timer.find('.TD').text(),
hours = $timer.find('.TH').text(),
minutes = $timer.find('.TI').text(),
seconds = $timer.find('.TS').text();
// ...
}, 1000)
})