jquery mouseenter() 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

enter

## English[ˈentə(r)] US[ˈɛntɚ]

vt.& vi. Enter; participate; start; register

jquery mouseenter() methodsyntax

Function:When the mouse pointer passes through an element, the mouseenter event occurs. This event is most often used in conjunction with the mouseleave event. The mouseenter() method triggers the mouseenter event, or specifies a function to run when the mouseenter event occurs. Unlike the mouseover event, the mouseenter event is only triggered when the mouse pointer passes through the selected element. If the mouse pointer passes through any child element, the mouseover event will also be triggered. See the example below for a demonstration.

Trigger mouseenter event syntax: $(selector).mouseenter()

Bind the function to mouseenter Event syntax: $(selector).mouseenter(function

Parameters:

##ParametersDescriptionfunction Optional. Specifies the function to run when the mouseenter event occurs.

jquery mouseenter() 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