用于启用 html 文本框的简单 onclick 函数不起作用...单击文本框时没有任何反应。使用变量作为 id 的一部分。
<script language="JavaScript">
function unlock(id)
{
document.getElementById('strain'+id).disabled=false;
return false;
}
</script>
<input id="strain343" type="text" value="54.24" onclick="return unlock(343);" disabled="true" name="strain"></input>
最佳答案
禁用的输入不会捕获点击事件。
另请参阅the specification :
<小时/>A form control that is disabled must prevent any click events that are queued on the user interaction task source from being dispatched on the element.
您需要重新考虑您的 UI,以避免该元素被禁用或避免需要单击它。
关于php - Javascript onclick 与 getElementById 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16424214/