i am creating an empty div in the javacript DOM. but when i call some function on it, for example,
var hover = document.createElement("div");
hover.className = "hover";
overlay.appendChild(hover);
hover.onClick = alert("hi");
the onClick function isnt working. instead it displays an alert as soon as it reaches the div creation part of the script. what am i doing wrong?