jQuery 마우스 이벤트 ...로그인

jQuery 마우스 이벤트 mouseenter() 이벤트

mouseenter()

정의 및 사용법

mouseenter 이벤트는 마우스 포인터가 요소를 통과할 때 발생합니다.

이 이벤트는 mouseleave 이벤트와 함께 가장 자주 사용됩니다.

mouseenter() 메서드는 mouseenter 이벤트를 트리거하거나 mouseenter 이벤트가 발생할 때 실행할 함수를 지정합니다.

참고: mouseover 이벤트와 달리 mouseenter 이벤트는 마우스 포인터가 선택한 요소를 통과할 때만 트리거됩니다. 마우스 포인터가 하위 요소를 통과하면 mouseover 이벤트도 트리거됩니다.

<html>
<head>
<meta charset="utf-8">
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
<script type="text/javascript">
x=0;
y=0;
$(document).ready(function(){
 $("div.over").mouseover(function(){
 $(".over span").text(x+=1);
 });
 $("div.enter").mouseenter(function(){
 $(".enter span").text(y+=1);
 });
});
</script>
</head>
<body>
<p>不论鼠标指针穿过被选元素或其子元素,都会触发 mouseover 事件。</p>
<p>只有在鼠标指针穿过被选元素时,才会触发 mouseenter 事件。</p>
<div class="over" style="background-color:lightgray;padding:20px;width:300px;">
<h2 style="background-color:white;">被触发的 Mouseover 事件:<span></span></h2>
</div>
</br></br>
<div class="enter" style="background-color:lightgray;padding:20px;width:300px;">
<h2 style="background-color:white;">被触发的 Mouseenter 事件:<span></span></h2>
</div>
</body>
</html>


다음 섹션
<html> <head> <meta charset="utf-8"> <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script> <script type="text/javascript"> x=0; y=0; $(document).ready(function(){ $("div.over").mouseover(function(){ $(".over span").text(x+=1); }); $("div.enter").mouseenter(function(){ $(".enter span").text(y+=1); }); }); </script> </head> <body> <p>不论鼠标指针穿过被选元素或其子元素,都会触发 mouseover 事件。</p> <p>只有在鼠标指针穿过被选元素时,才会触发 mouseenter 事件。</p> <div class="over" style="background-color:lightgray;padding:20px;width:300px;"> <h2 style="background-color:white;">被触发的 Mouseover 事件:<span></span></h2> </div> </br></br> <div class="enter" style="background-color:lightgray;padding:20px;width:300px;"> <h2 style="background-color:white;">被触发的 Mouseenter 事件:<span></span></h2> </div> </body> </html>
코스웨어