I have a website which displays the month and day of the user visiting. It works fine right now, but when I update my code, the .getdate script stops working.
I am not altering any part of the script-- even when I copy and paste the same code that is working right now and upload it as a new file, the script does not work. I am a beginner and self-taught, so perhaps this has a very simple solution.
Here is the script:
<script>
function myFunction() {
var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
var d = new Date();
var n = month[d.getMonth()] +' '+ [d.getDate()];
document.getElementById("date").innerHTML = n;
}
</script>
And here is how it is implemented in the code:
< h3 > today is < h3 id="date" >< /h3 >< h3 > and you can change the world< /h3 >< /h3 >
Again, as it is, the code is working on my website right now. However, any attempt to re-use the same code fails. It would stand to reason that I could copy and paste this code and it would achieve the same results. Any help is appreciated :)