수

.hover (handlerIn, handlerOut)

· 2017-10-19 (목) 23:53:47 · 1940

.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>

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

개발자팁

5,403건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
jQuery 17-11-24 조회 2,608
jQuery 17-11-24 조회 2,721
jQuery 17-11-21 조회 2,943
jQuery 17-11-21 조회 3,175
jQuery 17-11-21 조회 2,376
jQuery 17-11-10 조회 3,378
jQuery 17-11-10 조회 2,838
jQuery
[jQuery]
17-11-10 조회 2,175
JavaScript 17-11-09 조회 3,266
jQuery
[jQuery]
17-11-08 조회 1,997
jQuery 17-11-08 조회 2,268
jQuery 17-11-08 조회 2,355
jQuery 17-10-24 조회 2,137
jQuery 17-10-24 조회 2,208
jQuery
[jQuery]
17-10-24 조회 1,907
jQuery 17-10-20 조회 2,519
jQuery 17-10-20 조회 2,950
jQuery
[jQuery]
17-10-20 조회 2,241
jQuery 17-10-19 조회 1,941
jQuery
[jQuery]
17-10-19 조회 2,354
jQuery 17-10-19 조회 5,961
기타 17-10-19 조회 3,683
jQuery
[jQuery]
17-10-17 조회 2,084
jQuery 17-10-17 조회 2,243
jQuery 17-10-17 조회 2,345
PHP 17-10-16 조회 5,645
node.js 17-10-13 조회 4,699
jQuery 17-10-12 조회 2,739
jQuery 17-10-12 조회 2,169
jQuery 17-10-12 조회 1,737