Home > Web Front-end > JS Tutorial > body text

jQuery: usage and definition of mouseleave event

黄舟
Release: 2017-06-28 09:57:42
Original
1198 people have browsed it

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"); });
Copy after login

Example

When the mouse pointer leaves the element, change the background color of the element:

$("p").mouseleave(function(){
  $("p").css("background-color","#E9E9E4");
});
Copy after login

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()
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template