jquery mouseout() method


  Translation results:

mouse

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

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

vi.catching mice; spying, secretly searching

out

英[aʊt] 美[aʊt]

adv.Out; outside, outside; completely, thoroughly; published

prep. (indicates the source) from; (from...) to come out; (indicates not in the original state) to break away; leave

vt. To extinguish; to expose; to expel

adj. Outside; out; to step down; peripheral

n. Not popular; out

jquery mouseout() methodsyntax

Function:When the mouse pointer moves away from the element, the mouseout event occurs. This event is most often used together with the mouseover event. The mouseout() method triggers a mouseout event, or specifies a function to run when a mouseout event occurs. Unlike the mouseleave event, the mouseout event is triggered whether the mouse pointer leaves the selected element or any child element. The mouseleave event is only fired when the mouse pointer leaves the selected element. See the example below for a demonstration.

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

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

Parameters:

##ParameterDescriptionfunction Optional. Specifies the function to be run when a mouseout event occurs.

jquery mouseout() 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").mouseover(function(){
    $("p").css("background-color","yellow");
  });
  $("p").mouseout(function(){
    $("p").css("background-color","#E9E9E4");
  });
  $("#btn1").click(function(){
    $("p").mouseover();
  });  
  $("#btn2").click(function(){
    $("p").mouseout();
  }); 
});
</script>
</head>
<body>
<p style="background-color:#E9E9E4">请把鼠标指针移动到段落上。</p>
<button id="btn1">触发段落的 mouseover 事件</button><br />
<button id="btn2">触发段落的 mouseout 事件</button>
</body>
</html>
Run instance »

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