I have 2 elements - "span" (named "divLikedX") and "a" (named "aLikeX"). I have the following javascript (occurs clicking by "a"):
function CommentLike(CommentID, aLink) {
if (CommentID != null && CommentID > 0)
$.post("/Home/LikeComment", { CommentID: CommentID },
function () {
//alert($("#divLiked" + CommentID).is(':visible'));
/*alert($(aLink).text());*/if ($("#divLiked" + CommentID).is(':hidden')) {
$("#divLiked" + CommentID).show();
$("#aLike" + CommentID).text('Unlike');
} else {
$("#divLiked" + CommentID).hide();
$("#aLike" + CommentID).text('Like');
}
});
};
If I remove $("#aLike" + CommentID).text('Unlike'); and $("#aLike" + CommentID).text('Like'); strings I get the correct behavior. But with these strings it works correctly only first 2 clicks, after it alert($("#divLiked" + CommentID).is(':visible')) == "true" always. Why?
if (CommentID)