I want to create LIKE and UNLIKE button in jquery, what i did is ,
<span><a class="like-Unlike" href="">Like</a></span> |
function LikeUnLikeButton() {
$(".like-Unlike").click(function (e) {
if ($(this).html() == "Like") {
$(this).html('Unlike');
}
else {
$(this).html('Like');
}
});
}
but it is not working , problem is when i click on LIKE button i can see unlike button and again it’s back to LIKE button
Please check it out here : http://jsfiddle.net/mHJnH/
You have miss placed closing parenthesis of
$(this) is missing here.Change
To
Edit due to update in question
You may not need function LikeUnLikeButton() {
Live Demo