earlier I made a post: https://jsfiddle.net/dqj1x89z/
What I wanted to do is to apply a class on children elements based on the time that has passed, until now I managed to do something like that, besides what I already have there:
var childNodes = $('.tbi-phone-verification-loader').children();
function startTimer() {
timerInterval = setInterval(() => {
timePassed = timePassed += 1;
timeLeft = TIME_LIMIT - timePassed;
document.getElementById("base-timer-label").innerHTML = formatTime(timeLeft);
var intervalId = window.setInterval(function() {
// childNodes.each(function(){
// $('.tbi-phone-verification-loader div:nth-child(i)').css("background","red");
// })
for(var i = 0; i <= childNodes.length; i++) {
$('.tbi-phone-verification-loader div:nth-child('+i+')').css("background","red");
}
}, 10000)
// var formattedTimeLabel = $('.base-timer__label').html();
// formattedTimeLabel.replaceWith(`${formatTime(timeLeft)}`);
// if (timeLeft === 0) {
// onTimesUp();
// }
}, 1000);
}
I tried using for but it doesn't work, after 10 seconds all the circles are going red, I want every 10 seconds to fill a circle with the specified color.