$input.disabled = true;
Run Code Online (Sandbox Code Playgroud)
要么
$input.disabled = "disabled";
Run Code Online (Sandbox Code Playgroud)
哪种标准方式?而且,相反,如何启用禁用输入?
可能的原因是什么document.getElementById,$("#id")或者任何其他DOM方法/ jQuery选择器没有找到元素?
示例问题包括:
.val(),.html(),.text())返回undefined返回的标准DOM方法null导致以下任何错误:
未捕获的TypeError:无法设置null的属性'...'未捕获的TypeError:无法读取null的属性'...'
最常见的形式是:
未捕获的TypeError:无法设置null的属性'onclick'
未捕获的TypeError:无法读取null的属性"addEventListener"
未捕获的TypeError:无法读取null的属性'style'
我有一个复选框,在某些条件下,需要禁用.原来HTTP不会发布禁用的输入.
我怎么能绕过那个?提交输入,即使它被禁用并保持输入被禁用?
我编写了一些简单的代码,可以在单击按钮时启用和禁用输入字段,但它没有响应。请帮我...!!!
<html>
<head>
<script type="text/javascript">
function toggleEnable(el1, el2) {
document.getElementByID(el1).disabled = true;
document.getElementByID(el2).disabled = true;
}
</script>
</head>
<body>
<form>
<table>
<tr>
<td><input id="input1" class="myText" type="text" placeholder="Row 1" /></td>
<td><input id="input2" class="myText" type="text" placeholder="Row 1" /></td>
<td><button onclick="toggleEnable('input1','input2')"> Enable/Disable </button></td>
</tr>
<tr>
<td><input id="input3" class="myText" type="text" placeholder="Row 3" /></td>
<td><input id="input4" class="myText" type="text" placeholder="Row 4" /></td>
<td><button onclick="toggleEnable('input3','input4')"> Enable/Disable </button></td>
</tr>
</table>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我尝试将 readonly 属性设置为 true,但它不起作用,因为我仍然可以从下拉列表中选择值。
<tr>
<td>
<select name="type" tabindex="0">
<option value=""></option>
<option value="first">first</option>
<option value="second">second</option>
</select>
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)