I've been following examples but my fiddle isn't working. Here is the code:
var showMessage;
var divTag = document.getElementById("myDiv");
divTag.onClick = showMessage();
showMessage = function() {
alert("You clicked me.");
}
<div id="myDiv" style="height: 100px; width: 100px; background-color: pink;">
</div>
I'm probably missing something stupid but I cannot see it. I read out here that it is possible to put a click event on a div. Anybody know what I am doing wrong?
P.S. Yeah, I don't know how to decipher or fix the error.