arezzo
arezzo

Reputation: 2925

If this is how you disable an element with jQuery, how do you re-enable it?

How do you re-enable an element after disabling it this way?

$("#foo").attr("disabled", "disabled");

Upvotes: 1

Views: 78

Answers (3)

Michał Wojciechowski
Michał Wojciechowski

Reputation: 2490

Assuming you're using a recent version of jQuery (1.6+), a more appropriate way of toggling the disabled attribute is using .prop():

$("#foo").prop("disabled", true);
$("#foo").prop("disabled", false);

See jQuery API documentation for .prop() for an explanation.

Upvotes: 5

Ben Swinburne
Ben Swinburne

Reputation: 26467

$('#foo').removeAttr('disabled');

OR you can set attr to ""

$('#foo').attr('disabled', '');

Upvotes: 0

Abe Miessler
Abe Miessler

Reputation: 85056

This should do it:

$('#foo').removeAttr('disabled');

and this as well:

$('#foo').attr('disabled', '');

Upvotes: 3

Related Questions