Recently, I've been experimenting with creating a calendar but encountered a frustrating issue. I created a variable storing a date using the toLocaleDateString method. However, when attempting to modify a paragraph's inner HTML, nothing seemed to change. Below is the snippet of code that has been causing me trouble:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<meta charset="utf-8" />
<title>HTML Calendar</title>
<script>
var currentDate = new Date().toLocaleDateString();
document.getElementById("date").innerHTML = currentDate;
</script>
</head>
<body>
<p id="clock"></p>
<div id="cal">
<div id="headmonth"><p id="date"></p></div>
<div id="days"></div>
</div>
</body>
</html>