how do i change id of a element every time it is clicked with jquery
how do i change id of a element every time it is clicked with jquery? I
have this code which works fine on the first click, but then when clicked
again, it still calls the old id.
$("#like<? echo $msgID;?>").click(function(){
$.post("like.php?status_id=<? echo $msgID;?>", $(this).serialize());
setTimeout(function() {
$("#likeDiv<? echo $msgID;?>").load('like-count.php?status_id=<?
echo $msgID;?>');
$("#like<? echo $msgID;?>").attr("id","unlike<? echo
$msgID;?>").text("Unlike");
},500);
});
$("#unlike<? echo $msgID;?>").click(function(){
$.post("unlike.php?status_id=<? echo $msgID;?>",
$(this).serialize());
setTimeout(function() {
$("#likeDiv<? echo $msgID;?>").load('like-count.php?status_id=<?
echo $msgID;?>');
$("#unlike<? echo $msgID;?>").attr("id","like<? echo
$msgID;?>").text("Like");
},500);
});
No comments:
Post a Comment