+ 2
I need help with Js
Hello everyone, I need help with a JavaScript code that countdown time to a multiple times during day For example, i have X event that happens 5 times a day 12 am 6 am 12pm 4 pm 9pm I want the JavaScript to automatically change the countdown te to the next event time And those events are to be changed anytime But i can't figure out the way
3 Answers
+ 4
A hint will be to use for each event a new countdown variable. For more help let us see your attempt.
+ 2
Here a very easy example with two countdowns. The second you can start with a button.
Instead of that you can build a class countdown and build a structure etc. And call so many new objects as you want.
https://code.sololearn.com/Wy9nSdTIGE50/?ref=app
+ 1
getEventTimes: function() {
App.events_time = DmNConfig.timers;
if (App.isfirst == false) {
App.events();
App.isfirst = true;
}
},
events: function() {
i = 0;
for (i in App.events_time) {
newDiv = $("<div/>");
newDiv.append($("<span />").text(App.events_time[i].name));
newDiv.append($("<small />").attr({
id: 'event' + App.events_time[i].id
}).text(App.formatedTime(App.events_time[i].left)));
$("#events").append(newDiv);
i++;
}
setInterval(function() {
App.updateEventTimes()
}, 0);
},