0

Is their any possible when on click the button it change to only text and not as a button.

Ex:

I have Invite button for all individual user. What I need is when on click the Invite button, button text need not to change instead button is change to text.

"Invite" button format is change to "pending request" text format along with "cancel" button when on click the button.

4
  • Why not create a button and a text. Then you can choose which is which to show/hide. Commented Jul 18, 2013 at 6:41
  • make two butons and on click of one change the buttons. Commented Jul 18, 2013 at 6:42
  • refer link, stackoverflow.com/questions/1544317/… Commented Jul 18, 2013 at 6:44
  • Hide it as suggested by @JunM. Also make sure you disable the initial button when hiding to prevent double-click or Enter key. This is a relatively easy task with jQuery. Commented Jul 18, 2013 at 6:45

4 Answers 4

1

Hope it helps, this FIDDLE

if you want to learn more. read more about jquery.

html

<input id="invite" type="button" value="Invite" />
<span id="pending">Pending</span>
<input id="cancel" type="button" value="Cancel" />

script

$('#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');
});
Sign up to request clarification or add additional context in comments.

Comments

0

Try this code :

$('button').click(function() {
    $(this).replaceWith("pending request<button>cancel</button>")
})

Comments

0
$("#btnAddProfile").click(function(){
    $("#btnAddProfile").attr('value', 'pending request...');
//add cancel button
 });

Comments

0

If you have a button like this:

<button>Click me</button>

You can disable it on click with jQuery like this:

$(function() {
  $('button').on('click', function(e) {
    e.preventDefault();       
    $(this).prop('disabled', 'disabled');
  });
});

See fiddle here: http://jsfiddle.net/jpmFS/

Or replace it with only text like this:

$(function() {
 $('button').on('click', function(e) {
    e.preventDefault();       
    $(this).replaceWith('<p>'+$(this).text()+'</p>');
 });
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.