mercredi 1 janvier 2020

I would like to create a function that compares the hours from moment to a set of div classes (new to coding sorry if this is worded incorrectly)

I can get this to work creating many if statements by stating if moment.... === 12(example below) but I would like to consolidate it to one by pulling from my div classes labeled 9, 10, 11, 12, 1, 2, 3, 4, 5

`function hourTrack() {
 if (moment().hour() === 12)
 $(".12").css("background-color", "red");
 $( ".1, .2, .3, .4, .5,").css("background-color", "blue");
}` 

My thought process leads me to believe it should be something like

function hourTrack() { if (moment().hour() === parseInt(the div id number) }

Am I on the right track? Any help appreciated!

Aucun commentaire:

Enregistrer un commentaire