ボタンをクリックすると、ボタンではなくテキストのみに変更される可能性があります。
元:
すべての個々のユーザーに招待ボタンがあります。私が必要とするのは、招待ボタンをクリックしたときに、ボタンのテキストを変更する必要はなく、代わりにボタンがテキストに変更されることです。
「招待」ボタンのフォーマットは、ボタンをクリックすると「キャンセル」ボタンとともに「保留中のリクエスト」テキストフォーマットに変更されます。
それが役立つことを願っています、このフィドル
もっと学びたいなら。jqueryの詳細をお読みください。
html
<input id="invite" type="button" value="Invite" />
<span id="pending">Pending</span>
<input id="cancel" type="button" value="Cancel" />
脚本
$('#pending').hide();
$('#cancel').hide();
$('#invite').on('click', function () {
$(this).hide('fast');
$('#pending').show('fast');
$('#cancel').show('fast');
});
$('#cancel').on('click', function () {
$(this).hide('fast');
$('#pending').hide('fast');
$('#invite').show('fast');
});
このコードを試してください:
$('button').click(function() {
$(this).replaceWith("pending request<button>cancel</button>")
})
$("#btnAddProfile").click(function(){
$("#btnAddProfile").attr('value', 'pending request...');
//add cancel button
});