[jQuery] Add / Remove Class help
I have 2 class options .bookmarked and .not
<div id="b_97fd0f" class="bookmarked not"> </div>
Or
<div id="b_97fd0f" class="bookmarked"> </div>
My js looks like
$(".bookmarked,.bookmarked not").click(function() {
var url_id = $(this).attr('id').split('_');
var status = $(this).attr('class');
//alert(status);
$.ajax({
type: "POST",
url:
'/bookmarks/bookmark/'+url_id[1],
success: function(){
if (status = "bookmarked
not") {
//creating a bookmark
$('#b_'+url_id[1]).removeClass('not');
} else if (status = "bookmarked"){
//deleting the bookmark
$('#b_'+url_id[1]).addClass('not');
}
}
});
return false;
});
If I click on a ".bookmarked not" link it removes the "not" class, but if I
click on a "bookmarked" link it does not add the "not" class.
Now the bookmarks are being created and deleted in the database...just not
changingthe div class.
Ideas where I went wrong?
Dave