jQuery mouseenter() 메서드

❮ jQuery 이벤트 메소드

예시

마우스 포인터가 <p> 요소에 들어갈 때 배경색을 노란색으로 설정합니다.

$("p").mouseenter(function(){
  $("p").css("background-color", "yellow");
});

정의 및 사용

mouseenter 이벤트는 마우스 포인터가 선택된 요소 위에 있을 때 발생합니다.

mouseenter() 메서드는 mouseenter 이벤트를 발생시키거나, mouseenter 이벤트가 발생했을 때 실행할 함수를 첨부합니다.

참고: mouseover 이벤트 와 달리 mouseenter 이벤트는 마우스 포인터가 선택한 요소에 들어갈 때만 트리거됩니다. 마우스 포인터가 자식 요소에도 들어가면 mouseover 이벤트가 트리거됩니다. 데모는 페이지 끝에 있는 예제를 참조하십시오.

팁: 이 이벤트는 종종 mouseleave 이벤트 와 함께 사용됩니다 .


통사론

선택한 요소에 대해 mouseenter 이벤트를 트리거합니다.

$(selector).mouseenter()

mouseenter 이벤트에 함수를 연결하십시오:

$(selector).mouseenter(function)

Parameter Description
function Optional. Specifies the function to run when the mouseenter event is triggered

직접 해보십시오 - 예


의 차이점 mouseenter(), mouseover() 및 mousemove()의 차이점을 보여줍니다.


❮ jQuery 이벤트 메소드