The MouseOver event is triggered regardless of whether the mouse pointer passes through the selected element or its child elements, and corresponds to the mouseout
The MouseEnter event is triggered only when the mouse pointer passes through the selected element, which corresponds to the MouseLeave
The following example can help us to understand the difference between mouseover and MouseEnter:
1 <HTML>2 <Head>3 <Scripttype= "Text/javascript"src= "/jquery/jquery.js"></Script>4 <Scripttype= "Text/javascript">5 x=0;6 y=0;7 $ (document). Ready (function(){8 $("Div.over"). MouseOver (function(){9 $(". Over span"). Text (x+=1);Ten }); One $("Div.enter"). MouseEnter (function(){ A $(". Enter Span"). Text (y+=1); - }); - }); the </Script> - </Head> - <Body> - <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> + A <Divclass= "Enter"style= "Background-color:lightgray;padding:20px;width:40%;float:right"> at <H2style= "Background-color:white;">The Mouseenter event that is triggered:<span></span></H2> - </Div> - </Body> - </HTML>
1, $ ("Div.over"). MouseOver, when the mouse enters the <div></div> tag will count plus 1, when the mouse enters the
The MouseOver event is triggered regardless of whether the mouse pointer passes through the selected element or its child elements.
2, $ ("Div.over"). MouseEnter, when the mouse enters the <div></div> tag will count plus 1, when the mouse into the
The MouseEnter event is triggered only when the mouse pointer passes through the selected element.
Second, the following example can help us to understand the difference between mouseout and MouseLeave:
1 <HTML>2 <Head>3 <Scripttype= "Text/javascript"src= "/jquery/jquery.js"></Script>4 <Scripttype= "Text/javascript">5 x=0;6 y=0;7 $ (document). Ready (function(){8 $("Div.out"). Mouseout (function(){9 $(". Out span"). Text (x+=1);Ten }); One $("Div.leave"). MouseLeave (function(){ A $(". Leave span"). Text (y+=1); - }); - }); the </Script> - </Head> - <Body> - <Divclass= "Out"style= "Background-color:lightgray;padding:20px;width:40%;float:left"> + <H2style= "Background-color:white;">The Mouseout event that is triggered:<span></span></H2> - </Div> + <Divclass= "Leave"style= "Background-color:lightgray;padding:20px;width:40%;float:right"> A <H2style= "Background-color:white;">The MouseLeave event that is triggered:<span></span></H2> at </Div> - </Body> - </HTML>
1, $ ("Div.over"). Mouseout, when the mouse leaves the <div></div> tag will count plus 1, when the mouse left the
The Mouseout event is triggered regardless of whether the mouse pointer leaves the selected element or any child elements.
As shown, the Mouseout event is triggered at three blue dot locations.
2, $ ("Div.over"). MouseLeave, when the mouse leaves <div></div> tag will count plus 1, when the mouse left the
The MouseLeave event is triggered only when the mouse pointer leaves the selected element.
As shown, the MouseLeave event is triggered at the location of the blue Dot.
The difference between mouseover, mouseout, MouseEnter and MouseLeave in jquery