테스트 사이트 - 개발 중인 베타 버전입니다

.hover (handlerIn, handlerOut)

· 8년 전 · 1408

.hover (handlerIn, handlerOut)

설명 : 일치하는 요소에 두 개의 핸들러를 바인딩하여 마우스 포인터가 요소에 들어갔을 때 실행됩니다.

이 .hover()메서드는 양쪽 mouseenter및 mouseleave이벤트에 대한 처리기를 바인딩 합니다. 마우스를 요소 내에 사용하는 동안 요소에 비헤이비어를 적용하는 데 사용할 수 있습니다.

전화 $( selector ).hover( handlerIn, handlerOut )는 다음과 같이 단축됩니다.

1
$( selector ).mouseenter( handlerIn ).mouseleave( handlerOut );
에 대한 토론을 참조 .mouseenter()하고 .mouseleave()자세한 내용을.

예 :
특수 스타일을 추가하여 위에 놓은 항목을 나열하려면 다음을 시도하십시오.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>hover demo</title>
  <style>
  ul {
    margin-left: 20px;
    color: blue;
  }
  li {
    cursor: default;
  }
  span {
    color: red;
  }
  </style>
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
 
<ul>
  <li>Milk</li>
  <li>Bread</li>
  <li class="fade">Chips</li>
  <li class="fade">Socks</li>
</ul>
 
<script>
$( "li" ).hover(
  function() {
    $( this ).append( $( "<span> ***</span>" ) );
  }, function() {
    $( this ).find( "span:last" ).remove();
  }
);
 
$( "li.fade" ).hover(function() {
  $( this ).fadeOut( 100 );
  $( this ).fadeIn( 500 );
});
</script>
 
</body>
</html>

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

게시글 목록

번호 제목
15969
jQuery .jquery
15968
15967
jQuery .is()
15966
15965
15964
15963
15962
jQuery .index()
15961
15960
15959
jQuery .html()
15958
15957
jQuery .hide ()
15956
15955
15954
15953
15952
15949
15947
15946
15945
15944
15942
15941
15940
15939
15938
15937
15936