I wanted the page to detect if it was Thursday, and if it was display some text. I don't understand why this won't work. Is it because I can do = on a if than? Please explain, thank you!
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<p id="bleh"></p>
<script>
var day;
switch (new Date().getDay()) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
}
document.getElementById("demo").innerHTML = "Today is " + day;
</script>
<script>
function myFunction() {
if (day = 4;) {
document.getElementById("bleh").innerHTML = "Check your grades.";
}
}
</script>
</body>
</html>
P.S. I would use OnTime, but I am host my webpage off of github pages so I can't load it on there, this is why I'm working with this type of JS.
Aucun commentaire:
Enregistrer un commentaire