jQuery mouseout()Method

jQuery 事件方法jQuery Event Methods

Example

When the mouse pointer leaves the <p> element, set the background color to gray:

$("p").mouseout(function(){ $("p").css("background-color","gray"); });

Try it yourself »

Definition and Usage

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

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

Note:and mouseleaveDifference between events: 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 demonstration example at the bottom of the page.

Tip:This event is usually used together with the mouseoverevent.


Syntax

Trigger the mouseout event on the selected element:

$(selector).mouseout() Try it yourself

Attach a function to the mouseout event:

$(selector).mouseout(function) Try it yourself

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 事件方法jQuery Event Methods

Other Extensions