2011-03-03 2 views
0

나는 다음과 같은 코드가 있습니다 호출 클릭 기능 방법하지만 그것은 관련된 다른 클래스가있는 경우,

$('#commentContainer').delegate('div.comment-vote div.vote', 'click', function() { 

//etc 
} 

내가이 아니라 div.vote는 "인증되지 않은"

클래스가있을 때 호출되는 할을

어떻게 할 수 있습니까?

<div class="vote"></div>//this one when clicked call click function in delegate 

<div class="vote unauthenticated"></div>//this one do nothing. 

답변

1

not-selector[docs]을 사용하십시오.

$('#commentContainer').delegate('div.comment-vote div.vote:not(.unauthenticated)', 'click', function() { 

이제 click 이벤트는 하지unauthenticated 클래스가 할 div.vote 요소에 핸들러를 트리거합니다.

관련 문제