jQuery hover() 메서드
예시
마우스 포인터가 요소 위에 있을 때 <p> 요소의 배경색을 변경합니다.
$("p").hover(function(){
$(this).css("background-color", "yellow");
}, function(){
$(this).css("background-color", "pink");
});
정의 및 사용
hover() 메서드는 마우스 포인터가 선택한 요소 위에 있을 때 실행할 두 가지 함수를 지정합니다.
이 메서드는 mouseenter 및 mouseleave 이벤트를 모두 트리거합니다.
참고: 하나의 함수만 지정된 경우 mouseenter 및 mouseleave 이벤트 모두에 대해 실행됩니다.
통사론
$(selector).hover(inFunction,outFunction)
Parameter | Description |
---|---|
inFunction | Required. Specifies the function to run when the mouseenter event occurs |
outFunction | Optional. Specifies the function to run when the mouseleave event occurs |