Nas*_*ila 7 html javascript hidden visibility
如何通过单击HTML中的另一个按钮使按钮不可见?
我写的如下,但它不起作用.
<input type="button" onclick="demoShow();" value="edit" />
<script type="text/javascript">
function demoShow()
{ document.getElementsByName('p2').style.visibility="hidden"; }
</script>
<input id="p2" type="submit" value="submit" name="submit" />
Run Code Online (Sandbox Code Playgroud)
小智 10
写这个
隐藏
{document.getElementById("p2").style.display="none";}
Run Code Online (Sandbox Code Playgroud)
显示
{document.getElementById("p2").style.display="block";}
Run Code Online (Sandbox Code Playgroud)
对于可见:
document.getElementById("test").style.visibility="visible";
Run Code Online (Sandbox Code Playgroud)
对于隐形:
document.getElementById("test").style.visibility="hidden";
Run Code Online (Sandbox Code Playgroud)
使用id元素的 来执行相同的操作。
document.getElementById(id).style.visibility = 'hidden';
Run Code Online (Sandbox Code Playgroud)