开发者

jQuery's equivalent to 'enabling' an input

I have a disabled text input that loads as:

开发者_JAVA技巧
<input type="text" name="Email<%=i %>" disabled="disabled" />

I'd like the jQuery statement that enables it. Seems like:

$("email0").attr("enabled");

should be close but doesn't work.


Use .removeAttr() like this:

$("input").removeAttr("disabled");

Or .attr() like this:

$("input").attr("disabled", false);


You can simply remove the disabled attribute:

$("input[name=email0]").removeAttr("disabled");

Note that the selector "email0" in your example will not match anything, you are looking for an input element that has a name attribute containing "email0".


$("email0").attr("enabled");

… would get the value of the enabled attribute, which would be undefined since there isn't one.

You want:

$("email0").removeAttr("disabled");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜