I'm a newcomer to the world of javascript and Iām struggling to understand why the code below isn't functioning correctly:
var displayMessage = document.getElementById("notification");
displayMessage.addEventListener("click", function() {
this.innerHTML = "New Message!";
});
<p id="notification">You have a new notification.</p>
Despite thoroughly researching event listeners, I am unable to determine what is causing this code to fail. Any help would be greatly appreciated. Thank you.