Hello everyone! I'm new here so please bear with me if I make any mistakes. Can someone take a look and tell me what I'm doing wrong?
I've created divs named "1st", "2nd", "3rd," etc., with the intention of setting up an advent calendar layout where the content of each day's div becomes visible only on that specific date.
In the test case below, I've used dates ranging from the 6th to the 8th, but unfortunately, the divs remain visible at all times.
Since I'm still learning JavaScript, I would really appreciate any assistance!
<script type = "text/javascript">
function myFunction() {
var num = new Date().getDate(); //current date as a number
if ((num <= 6)) {
document.getElementById('6th').style.display = "none";
}
if ((num <= 7)) {
document.getElementById('7th').style.display = "none";
}
if ((num <= 8)) {
document.getElementById('8th').style.display = "none";
}
}
</script>
<div id="6th">
6th
</div>
<div id="7th">
7th
</div>
<div id="8th">
8th
</div>