我正在使用JavaScript来禁用按钮。工作正常IE但不是在Firefox和Chrome,这里是我工作的脚本:document.getElementById('btnid')。disabled在firefox和chrome中不工作
function disbtn(e) {
if (someCondition == true) {
document.getElementById('btn1').disabled = true;
} else {
document.getElementById('btn1').disabled = false;
}
而且在我的HTML我有:
<input type="button" id="btn1" value="submit" />
没有错。它以什么方式不起作用? – Utkanos 2012-07-31 10:00:41
按钮禁用和启用在IE中正常工作。但是Firefox和Chrome没有任何事情发生。在这两个浏览器中,按钮没有任何功能,只能启用。 – steeve 2012-07-31 10:07:13
@Spencer:使用'setAttribute()'和'removeAttribute()'作为我在下面的答案中给出的。 – 2012-07-31 10:09:07