Код: Выделить всё
// all the objects with the timer
var wrappers = document.querySelectorAll(".collection-item");
wrappers.forEach(function(wrapper) {
var countDownDate = new Date("July 15, 2023 00:00:00").getTime();
var x = setInterval(function() {
var now = new Date().getTime();
var distance = countDownDate - now;
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// update the HTML elements within the current wrapper
wrapper.querySelector("#day").innerHTML = days;
wrapper.querySelector("#hour").innerHTML = hours;
wrapper.querySelector("#minute").innerHTML = minutes;
wrapper.querySelector("#second").innerHTML = seconds;
if (distance < 0) {
clearInterval(x);
carWrapper.querySelector(".announcement").innerHTML = "Yay!";
}
}, 1000);
});
Код: Выделить всё
[url=/books/000001]
00
00
00
00
[/url]
script from above here
Подробнее здесь: https://stackoverflow.com/questions/766 ... dividually
Мобильная версия