这里向大家描述一下HTML DOM display属性的定义和用法,HTML DOM display属性主要用来设置元素如何显示,比如当此属性值为none时,表示此元素不会被显示,而block则表示此元素将显示为块级元素,此元素前后会带有换行符。
HTML DOM display属性定义和用法
此属性主要用来设置元素如何显示。
语法:
Object.style.display=value
可能的值
HTML DOM display属性实例
本例设置不显示元素:
<html>
<head>
<script type="text/javascript">
function removeElement()
{
document.getElementById("p1").style.display="none";
}
</script>
</head>
<body>
<h1>Hello</h1>
<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>
<input type="button" onclick="removeElement()"
value="Do not display paragraph" />
</body>
</html>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
【编辑推荐】
- CSS display属性基本特性和语法
- 探究CSS hack使用原理 规则及弊端
- 深入探究DIV CSS布局中position属性用法
- CSS属性display:inline-block使用揭秘
- CSS hack:实现IE6、IE7、Firefox兼容