Once you click to up-vote it becomes enabled, it can only be disabled by clicking the down-vote. How do I make it so that if I click to an enabled button it will become disabled.
$("a.vote_down").click(function() {
//get the id
the_id = $(this).attr('id');
//the main ajax request
$.ajax({
type: "POST",
data: "action=vote_down&id="+$(this).attr("id"),
url: "votes.php",
success: function(msg) {
$(".vote_down").addClass("active");
$(".vote_up").removeClass("active");
$("span#votes_count").html(msg);
}
});
});
One of the links:
<a href='javascript:;' class='vote_up<?php if($liked["points"]=="1") echo " active";?>' id='<?php echo $id; ?>'>Vote Up</a>
Try using this as a live click event on the
activeclass. Added some abstraction.working example: http://jsfiddle.net/hunter/XQfgU/ (minus the AJAX)