2011-03-03 38 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事件將觸發僅在div.vote元素做unauthenticated類的處理程序。

相關問題