visibility 属性设置元素是否可见。
</>code
- Object.style.visibility=visible|hidden|collapse
值 | 描述 |
---|---|
visible | 默认。元素框是可见的。 |
hidden | 元素框不可见,但仍然影响布局。 |
collapse | 当在表格元素中使用时,此值可删除一行或一列,但是它不会影响表格的布局。被行或列占据的空间会留给其他内容使用。如果此值被用在其他的元素上,会呈现为 "hidden"。 |
下面的例子隐藏一段文本:
</>code
- <html>
- <head>
- <script type="text/javascript">
- function changeVisibility()
- {
document.getElementById("p1").style.visibility="hidden";
- }
- </script>
- </head>
- <body>
- <p id="p1">This is some text. This is some text. This is some text.
- This is some text. This is some text. This is some text.
- This is some text. This is some text. This is some text.</p>
- <form>
- <input type="button" onclick="changeVisibility()"
- value="Hide paragraph" />
- </form>
- </body>
- </html>
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号