开发者

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

开发者 https://www.devze.com 2023-04-12 03:49 出处:网络
How do you re-enable an element after disabling it开发者_如何学运维 this way? $(\"#foo\").attr(\"disabled\", \"disabled\");

How do you re-enable an element after disabling it开发者_如何学运维 this way?

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


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.


This should do it:

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

and this as well:

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


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

OR you can set attr to ""

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号