9

I can disable it fine using this:

button.attr('disabled', 'disabled' ).addClass( 'ui-state-disabled' );

But how do I re-enable it? When I use this:

button.attr('enabled', 'enabled' ).addClass( 'ui-state-enabled' );

It doesn't work.

1
  • 3
    There is no attribute called 'enabled'. Commented Jan 27, 2011 at 16:37

5 Answers 5

21
button.removeAttr('disabled').removeClass( 'ui-state-disabled' );
Sign up to request clarification or add additional context in comments.

1 Comment

Is there a way to disable the button without removing its hover functionality?
5

Tried all the answers here and nothing worked for me.

The issue is that I have html:

<input type="submit" value="Save" id="saveButton" disabled="disabled" />

Then I call globaly:

$("button, input:submit, input:button").button();

After that the button gets attribute aria-disabled=true.

Neither of following will enable the submit:

$("#saveButton").attr('disabled',false);
$("#saveButton").removeAttr('disabled');
$("#saveButton").prop('disabled',false);
$("#saveButton").attr('aria-disabled',false);
$("#saveButton").removeClass('ui-state-disabled' );

The only working solution in this case is:

$("#saveButton").button( "enable" );

jQuery UI Docs: Button Widget - enable()

To disable button again:

$("#saveButton").button( "disable" );

jQuery UI Docs: Button Widget - disable()

2 Comments

Hint: Disabling works similar, see this linked answer.
This is the correct answer. This way you're essentially telling jQuery to enable the button and having it do all the work. If you want to do the work yourself, you have to remove the disabled attribute, the jQuery UI disabled classes, and set up the hover classes. No need to do all that by hand.
0

With jquery you can use removeAttr and removeClass to get rid of your disabled attribute/class:

button.removeAttr('disabled').removeClass('ui-state-disabled');

Comments

0

Just remove the disabled attribute.

http://api.jquery.com/removeAttr/

button.removeAttr("disabled")

Comments

0

I think that this is what are you looking for:

button.removeAttr("disabled");

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.