When entering a DOM element, mouseover
event will happen. Upon moving the mouse around the current element, no event happens, as mouseover
is for entering.
However, this rule is not obeyed for child nodes. If moving the mouse over child nodes, the mouseover
event will be triggered again and again, though no new event, as we are still in the original parent.
See this example. If we move the mouse over the parent (actually on its textNode), nothing new happens, but if we go to the child element (still on the parent), it will trigger the mouseover
event again and again. In fact it will fire the mouse event every time mouse enters an elements (even inside the original parent element).
How we can make the mouseover
only once for moving all over the parent (the original element in the addEventListener
)? In the given example, I mean to avoid firing the event upon moving the mouse on the child element.