Javascript 更改按钮的禁用属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4538685/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 12:50:18 来源:igfitidea点击:
changing disabled property of a button
提问by akshay
I have an html button, and I have dynamically disabled it using the following property values
我有一个 html 按钮,我使用以下属性值动态禁用了它
disabled="disabled"
How can i make it work again? i dont want to make it disabled now
我怎样才能让它再次工作?我不想现在禁用它
回答by Nick Craver
You can just set the disabled
propertyto false
in JavaScript, like this:
您可以只设置disabled
属性来false
在JavaScript中,像这样的:
document.getElementById("myId").disabled = false;
回答by miqbal
var e = document.getElementById("someElement");
e.removeAttribute("disabled");
and disable again,
并再次禁用,
e.setAttribute('disabled','disabled');