+ 1
Can you change an image according to the hour and minute of the day?
this is the script but it does not comply with what I ask for I am new to this function carregar (){ var img = document.getElementById("imagem") var data = new Date() var hora = data.getHours() var min = data.getMinutes() if(hora >= 5 && min>= 00 && hora <=7 && min<=30 ){ img.src = "0.jpg" }else if(hora >= 7 && min>= 30 && hora <=9 && min<=30 ){ img.src = "1.jpg" }else{ img.src = "2.jpg" } }
2 Réponses
+ 1
Add:
onload=()=>carregar()
0
You use it according to 24-digit.
If you're are trying to change the omg when it's 5, use
...hora>=17...