1. 程式人生 > >mouseenter與mouseover的區別

mouseenter與mouseover的區別

mouseenter | onmouseenter event

The event fires only if the mouse pointer is outside the boundaries of the object and the user moves the mouse pointer inside the boundaries of the object. If the mouse pointer is currently inside the boundaries of the object, for the event to fire, the user must move the mouse pointer outside the boundaries of the object and then back inside the boundaries of the object.

只有當滑鼠指標在物件的邊界之外,使用者把滑鼠移動到物件的邊界內時,事件mouseenter才觸發。如果滑鼠當時正在邊界內,使用者想要觸發該事件,需要把滑鼠移動到物件邊界外再移動到邊界內。
這裡寫圖片描述

因此,mouseenter不支援事件冒泡,所以導致在一個元素的子元素上進入或離開的時候會觸發其mouseover和mouseout事件,但是卻不會觸發mouseenter和mouseleave事件。