Home >Web Front-end >JS Tutorial >jQuery: usage and definition of mouseleave event
Overview
The mouseleave event occurs when the mouse pointer leaves an element. This event is most often used in conjunction with the mouseenter event.
Unlike the mouseout event, the mouseleave event will only be triggered when the mouse pointer leaves the selected element. If the mouse pointer leaves any child element, the mouseout event will also be triggered.
Parameters
fnFunctionV1.0
The processing function bound in the mouseleave event of each matching element.
[data],fnString,FunctionV1.4.3
data:mouseleave([Data], fn) Data can be passed in for function fn to process.
fn: The handler function bound in the mouseleave event of each matching element.
Example
Description:
Change the background color of the element when the mouse pointer leaves the element::
jQuery Code:
$("p").mouseleave(function(){ $("p").css("background-color","#E9E9E4"); });
Example
When the mouse pointer leaves the element, change the background color of the element:
$("p").mouseleave(function(){ $("p").css("background-color","#E9E9E4"); });
Definition and usage
When the mouse pointer leaves the element, The mouseleave event occurs.
This event is most often used together with the mouseenter event.
mouseleave() method triggers the mouseleave event, or specifies a function to run when the mouseleave event occurs.
Note: Unlike the mouseout event, the mouseleave event will only be triggered when the mouse pointer leaves the selected element. If the mouse pointer leaves any child element, the mouseout event will also be triggered. See the example below for a demonstration.
Try it yourself: the difference between mouseleave and mouseout
Trigger the mouseleave event
Syntax
$(selector).mouseleave()
The above is the detailed content of jQuery: usage and definition of mouseleave event. For more information, please follow other related articles on the PHP Chinese website!