Latest web development tutorials

jQuery mouseleave () method

jQuery Event Methods jQuery Event Methods

Examples

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

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

try it"

Definition and Usage

When the mouse pointer leaves the selected element, mouseleave event occurs.

mouseleave () method triggers mouseleave event or add a function to run when the event occurs mouseleave.

Note: Unlike mouseout event different, mouseleave event only when the mouse pointer leaves the selected element is triggered, mouseout event the mouse pointer leaves any child elements will also be triggered when.See the bottom of the page presentation instance.

Note: This event is usually associated with mouseenter use incident.


grammar

Trigger the selected element mouseleave events:

$(selector).mouseleave() 尝试一下

Adding Functions to mouseleave event:

$(selector).mouseleave(function) 尝试一下

参数 描述
function 可选。规定 mouseleave 事件触发时运行的函数。


Examples

More examples

Different mouseleave () and mouseout () between
Different Demo mouseleave () and mouseout () between.


jQuery Event Methods jQuery Event Methods