2009-10-26 3 views

답변

7

예, 여전히 유용합니다. live()은 특정 이벤트에서만 작동하며, livequery()은 사용자 브라우저가 제공하는 모든 이벤트에 바인딩 할 수 있습니다.

http://docs.jquery.com/Events/live

가능한 이벤트 값 : 현재 지원되지click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, keydown, keypress, keyup

: 또한 지원되지 않는 touchstart, touchend 같은 터치 이벤트가blur, focus, mouseenter, mouseleave, change, submit

주 등

2

livequery()이 제공하는 유용한 기능 중 하나 인 live()은 새 요소가 일치 할 때마다 (또는 요소가 더 이상 일치하지 않는 경우) 사용자 지정 함수를 실행하는 기능입니다. 에서

docs :

라이브 쿼리도 가지고 그것을 는 요소가 더 이상없는 경우에 새로운 요소와 다른 기능 (콜백)과 일치 불 함수 (콜백) 할 수있는 능력 일치. 이 은 궁극적 인 유연성을 제공하고 언급하지 않은 사용 사례를 제공합니다. 예를 들어 다음 코드는 라이브 쿼리를 사용하여 jQuery 호버 도우미 메서드를 구현하고 요소가 더 이상 일치하지 않을 때이를 제거합니다.

$('li') 
    .livequery(function(){ 
    // use the helper function hover to bind a mouseover and mouseout event 
     $(this) 
      .hover(function() { 
       $(this).addClass('hover'); 
      }, function() { 
       $(this).removeClass('hover'); 
      }); 
    }, function() { 
     // unbind the mouseover and mouseout events 
     $(this) 
      .unbind('mouseover') 
      .unbind('mouseout'); 
    }); 
관련 문제