我有以下代码:
$('#commentContainer').delegate('div.comment-vote div.vote', 'click', function () {
//etc
}
我希望这个被调用但是当div.vote还有一个类“unauthenticated”时
我该怎么做?
<div class="vote"></div>//this one when clicked call click function in delegate
<div class="vote unauthenticated"></div>//this one do nothing.
答案 0 :(得分:1)
$('#commentContainer').delegate('div.comment-vote div.vote:not(.unauthenticated)', 'click', function () {
现在,click
事件将仅在不具有div.vote
类的unauthenticated
元素上触发处理程序。