I have an anchor in the website. When someone clicks on it I do smth in jquery and change name, but when it is clicked again event is fired, despite I’ve changed it’s name.
code here:
$(".like_cont a[name=like]").click(function (e) {
alert("W");
var t = $(this);
t.find("img").attr("src", "images/like_icon.png");
var ls = parseInt(t.next().next()) + 1;
t.next().next().text(ls);
var params = "Like|" + t.attr("lik");
CallServer(params, "");
t.attr("name", "liked");
e.preventDefault();
});
after Click name is liked but another click events Fire. How to change selector to preserve firing?
One possible way would be to call .off() to remove the click event from your object.