Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery mouseout() method

jQuery mouseout() method

jQuery event methods jQuery event methods

Example

When the mouse pointer leaves the

element, set the background color to gray:

$

(

"

p

"

)

.

mouseout

(

function

(

)

{

$

(

"

p

"

)

.

css

(

"

background-color

"

,

"

gray

"

)

;

}

)

;

Try it »


Definition and Usage

The mouseout event occurs when the mouse pointer leaves the selected element.

The mouseout() method triggers the mouseout event, or adds a function to run when a mouseout event occurs.

**Note:** Unlike the mouseleave event, the mouseout event is triggered when the mouse pointer leaves the selected element or any child element, while the mouseleave event is only triggered when the mouse pointer leaves the selected element. See the demo at the bottom of the page.

**Tip:** This event is usually used together with the mouseover event.


Syntax

Trigger the mouseout event of the selected element:

$(

selector

).mouseout()

Try it

Add a function to the mouseout event:

$(

selector

).mouseout(

function

)

Try it

Parameters Description
function Optional. Specifies the function to run when the mouseout event is triggered.

More examples

The difference between mouseout() and mouseleave()
Demonstrate the difference between mouseout() and mouseleave().


jQuery event methods jQuery event methods