jquery mouseleave() method


  Translation results:

mouse

English [maʊs] American [maʊs]

n. Mouse; mouse; shy [timid] person; [informal term] eye bruises on the head

vi.Catch mice; spy, secretly search

leave

英[li:v] 美[liv]

vt.Leave; abandon; forget to bring; entrust

vt.& vi.Leave; set off; abandon

n.Permission; vacation; farewell; permission

jquery mouseleave() methodsyntax

Function:When the mouse pointer leaves the element, the mouseleave event occurs. This event is most often used together with the mouseenter event. The mouseleave() method triggers the mouseleave event, or specifies a function to run when the mouseleave event occurs. Unlike the mouseout event, the mouseleave event is only 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.

Trigger the mouseleave event syntax: $(selector).mouseleave()

Bind the function to the mouseleave event syntax: $ (selector).mouseleave(function)

Parameters:

ParametersDescription
function Optional. Specifies the function to run when the mouseleave event occurs.

jquery mouseleave() methodexample

<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("p").mouseenter(function(){
    $("p").css("background-color","yellow");
  });
  $("p").mouseleave(function(){
    $("p").css("background-color","#E9E9E4");
  });
});
</script>
</head>
<body>
<p style="background-color:#E9E9E4">请把鼠标指针移动到这个段落上。</p>
</body>
</html>
Run instance »

Click the "Run instance" button to view the online instance

Home

Videos

Q&A