About Event mouseover, mouseout, mouseenter,mouseleave differences _javascript skills

Source: Internet
Author: User

Recently in the online exam and course shopping mall have encountered such a problem: that is, when the mouse is sliding over a layer, when the mouse slide to the current layer words mouseover and mouseout in the lower version of the browser will appear flashing phenomenon, the solution to this phenomenon are many, But I think one of the simplest is to replace mouseover and mouseout with the corresponding MouseEnter and MouseLeave.

The MouseOver event occurs when the mouse pointer is over the element.

This event is most often used in conjunction with the Mouseout event.

Note: Unlike the MouseEnter event, the MouseOver event is triggered regardless of whether the mouse pointer crosses the selected element or its child elements. The MouseEnter event is triggered only when the mouse pointer crosses the selected element.

Note: Unlike the MouseLeave event, the Mouseout event is triggered regardless of whether the mouse pointer leaves the selected element or any child elements. The MouseLeave event is triggered only when the mouse pointer leaves the selected element. Take a look at the demo in the example below.

The MouseEnter event occurs when the mouse pointer crosses an element. This event is most often used in conjunction with the MouseLeave event.

Note: mouseover, mouseout also triggers an event when the mouse pointer crosses a child element of the selected element. This is sometimes an unexpected bug when binding an event that may be caused by the MouseOver mouseout event

MouseOver and MouseEnter

The MouseOver event is triggered regardless of whether the mouse pointer crosses the selected element or its child elements.

The MouseEnter event is triggered only when the mouse pointer crosses the selected element.

Mouseout and MouseLeave

The Mouseout event is triggered regardless of whether the mouse pointer leaves the selected element or any child elements.

The MouseLeave event is triggered only when the mouse pointer leaves the selected element.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.