Wil*_*est -2 javascript hidden input toggle
我有一个需要隐藏在页面加载上的div和输入.这是另一个指定,因此如果其他字段之一被选为"其他",那么div应该显示.但是输入元素没有隐藏在页面加载上.一旦我从它隐藏的div中取出输入元素,但是只要我将输入元素放回去它就不会隐藏,我做错了什么?
<head>
<script>
function hideother() {
document.getElementById("otherdiv").style.visibility = "hidden";
document.getElementById("others").style.visibility = "hidden";
}
</script>
</head>
<body onLoad="hideother()">
<!-- 2A OTHER SPECIFY -->
<div class="otherdiv">
<label for="otherspecify">Please specify other:</label>
<label id="error-2" style="text-transform:capitalize; color:red"> </label>
<br>
<input maxlength="30" name="others" id="others" type="text" class="form-control" placeholder="Other Specify" autocomplete="off" style="width:300px" />
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
更改
<div class="otherdiv">
Run Code Online (Sandbox Code Playgroud)
至
<div id="otherdiv">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
89 次 |
| 最近记录: |