The difference between jquery mouseover and Mouseenter,mouserout and MouseLeave

Source: Internet
Author: User

MouseOver and MouseEnter
The MouseOver event is triggered regardless of the mouse pointer passing through the selected element or its child elements
The MouseEnter event is triggered only when the mouse pointer passes through the selected element

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Scripttype= "Text/javascript"src= "Jquery-1.6.4.min.js"></Script><Scripttype= "Text/javascript">x=0; y=0; $ (document). Ready (function(){  $("Div.over"). MouseOver (function(){    $(". Over span"). Text (x+=1);  }); $("Div.enter"). MouseEnter (function(){    $(". Enter Span"). Text (y+=1); });});</Script></Head><Body><P>The MouseOver event is triggered regardless of whether the mouse pointer passes through the selected element or its child elements.</P><P>The MouseEnter event is triggered only when the mouse pointer passes through the selected element.</P><Divclass= "Over"style= "Background-color:lightgray;padding:20px;width:40%;float:left"><H2style= "Background-color:white;">The Mouseover event that is triggered:<span></span></H2></Div><Divclass= "Enter"style= "Background-color:lightgray;padding:20px;width:40%;float:right"><H2style= "Background-color:white;">The Mouseenter event that is triggered:<span></span></H2></Div></Body></HTML>
View Code

Mouseout and MouseLeave
Mouseout event is triggered regardless of whether the mouse pointer leaves the selected element or any child element
The MouseLeave event is triggered only when the mouse pointer leaves the selected element.

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Scripttype= "Text/javascript"src= "Jquery-1.6.4.min.js"></Script><Scripttype= "Text/javascript">x=0; y=0; $ (document). Ready (function(){  $("Div.over"). MouseLeave (function(){    $(". Over span"). Text (x+=1);  }); $("Div.enter"). Mouseout (function(){    $(". Enter Span"). Text (y+=1); });});</Script></Head><Body><P>The Mouseout event is triggered whenever the mouse pointer leaves the selected element or any child element.</P><P>The MouseLeave event is triggered only when the mouse pointer leaves the selected element.</P><Divclass= "Over"style= "Background-color:lightgray;padding:20px;width:40%;float:left"><H2style= "Background-color:white;">The Mouseover event that is triggered:<span></span></H2></Div><Divclass= "Enter"style= "Background-color:lightgray;padding:20px;width:40%;float:right"><H2style= "Background-color:white;">The Mouseenter event that is triggered:<span></span></H2></Div></Body></HTML>
View Code

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.