点击代码上的Jquery会影响具有特定类的每个元素,而不仅仅是单击的元素。例如,当我点击1张图片上的upvote时,所有图像的upvote按钮都会变灰,我怎么能让它只影响我点击的按钮。这是我的代码:
if (action.val() == 'upvote') {
if (!$('.arrowUp').hasClass('arrowUpDisabled')) {
$('.arrowUp').addClass('arrowUpDisabled');
if ($('.arrowDown').hasClass('arrowDownDisabled')) {$('.arrowDown').removeClass('arrowDownDisabled');}
$.post('../includes/voting.inc.php', {id: id.val(), userId: userId.val(), action: action.val()}, function(data){
ratingNumber.html((data));
}, 'json');
}
} else if (action.val() == 'downvote') {
if (!$('.arrowDown').hasClass('arrowDownDisabled')) {
$('.arrowDown').addClass('arrowDownDisabled');
if ($('.arrowUp').hasClass('arrowUpDisabled')) {$('.arrowUp').removeClass('arrowUpDisabled');}
$.post('../includes/voting.inc.php', {id: id.val(), userId: userId.val(), action: action.val()}, function(data){
ratingNumber.html((data));
}, 'json');
}
};