I want to loop a function changing the variable each time it runs until all variables are used. Currently, I have this function duplicated 20+ times changing out the "sa_g_week" for each one.
if (sa_g_week_24_7 !== "yes" && sa_g_week_24_7 !== "closed" &&
sa_g_week_24_7 !== 'n/a') {
if (hkg_time >= sa_g_week_start && hkg_time < sa_g_week_end) {
if (hkg_time >= sa_g_week_soon && hkg_time < sa_g_week_end) {
document.getElementById("sa_gdot").classList.add('close_soon');
document.getElementById("sa2_gdot").classList.add('close_soon');
} else {
document.getElementById("sa_gdot").classList.add('open');
document.getElementById("sa2_gdot").classList.add('open');
}
} else {
document.getElementById("sa_gdot").classList.add('closed');
document.getElementById("sa2_gdot").classList.add('closed');
}
}
if (sa_g_week_24_7 == "yes") {
document.getElementById("sa_gdot").classList.add('open');
document.getElementById("sa2_gdot").classList.add('open');
}
Aucun commentaire:
Enregistrer un commentaire