开发者

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");


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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜