selected
removeClassは、以下のjsのクラスを削除しませんdiv.upvote
が、addClass()は正常に機能します。何故ですか?
$(document).ready(function () {
"use strict";
$('div.upvote').click(function () {
var id = $(this).parents('li.book').attr('id');
var vote_type = 'up';
if ($(this).hasClass('selected')) {
var vote_action = 'recall-vote';
$.post('/b/vote/', {id: id, type: vote_type, action: vote_action}, function (response) {
if ($.isNumeric(response)) {
$('li#' + id)
.find('div.upvote')
.removeClass('selected');
$('div.vote-tally span.num').html(response);
}
});
} else {
var vote_action = 'vote';
$.post('/b/vote/', {id: id, type: vote_type, action: vote_action}, function (response) {
if ($.isNumeric(response)) {
$('li#' + id)
.find('div.upvote')
.addClass('selected');
$('div.vote-tally span.num').html(response);
}
});
}
});
}