Jam*_*lle 82 javascript attributes input
如何使用javascript从HTML输入中删除"禁用"属性?
<input id="edit" disabled>
Run Code Online (Sandbox Code Playgroud)
在onClick我希望我的输入标签不包含"禁用"属性.
Dav*_*und 172
将元素的disabled属性设置为false:
document.getElementById('my-input-id').disabled = false;
Run Code Online (Sandbox Code Playgroud)
如果你使用的是jQuery,那么等效的是:
$('#my-input-id').prop('disabled', false);
Run Code Online (Sandbox Code Playgroud)
对于多个输入字段,您可以通过类访问它们:
var inputs = document.getElementsByClassName('my-input-class');
for(var i = 0; i < inputs.length; i++) {
inputs[i].disabled = false;
}
Run Code Online (Sandbox Code Playgroud)
document例如,在哪里可以用表单替换,以仅查找该表单内的元素.您还可以使用getElementsByTagName('input')获取所有输入元素.在您的for迭代中,您必须检查它inputs[i].type == 'text'.