In the example below you can change the selector from all elements * to whichever elements you wish to restrict the detection of mouseenter events. For example if you only want to get notified when the mouse is over elements with class="example", change the line document.querySelectorAll("*") to document.querySelectorAll(".example").