my instructions are to Include a function defined via a function expression that displays the current date and time in an h2 at the top of the page when the page is opened. Add an id=”dateDisplay” to the h2. Include a self-invoking function that changes the color of the date text that was printed by the first function.
Im a bit confused on how to accomplish this. I tried to do a function expression to display the date but i get nothing shown and no errors. I tried to do a body onload to call the function but that result in a console error of function not defined.
HTML
<div>
<h2 id="dateDisplay"></h2>
</div>
Javascript
var d = new Date();
var x = function dateDisplay(){
document.getElementById("dateDisplay").value = d;
}
I'm really confused by the instructions. What exactly am I suppose to do to get this in working order.
edited: I had an error with my link to my js file. The issue now is I get console error document.getElementById... is null weather i use innerHTML or value or .innerText