You want the target events to be onmouseover , so you can access the properties of the element:
<script> document.onmouseover = function(e) { console.log(e.target.id); } </script>
See Cross-browser event properties for a goal (the following example from the aforementioned website):
function doSomething(e) { var targ; if (!e) var e = window.event; if (e.target) targ = e.target; else if (e.srcElement) targ = e.srcElement; if (targ.nodeType == 3)
To bring them together:
document.onmouseover = function(e) { var targ; if (!e) var e = window.event; if (e.target) targ = e.target; else if (e.srcElement) targ = e.srcElement; if (targ.nodeType == 3)
source share