jqueryを使用してこのリンクのIDをその場で変更するのに問題があります。リンクテキストは変更できますが、IDは変更できません。何か案は?
<a href="#" id="follow-5">follow</a>
リンクをクリックすると、次のように表示されます。
<a href="#" id="following-5">following</a>
これが私のjqueryコードです
$("a[id^='follow']").live('click', function(e) {
e.preventDefault();
var aid = $(this).attr('id').substring(7);
$.ajax({
type: "POST", url: "/artist/", data: "command=becomeFan&aid=" + aid,
dataType: "html",
success: function(data){
$("#follow-" + aid).text("Following");
$("#follow-" + aid).prev("a").attr("id","following-" + aid);
}
});
return false;
});