您的位置:首页 > Web前端 > CSS

CSS的display属性,显示或隐藏元素

2013-12-30 18:00 585 查看
<html>
<head>
<script type="text/javascript">
function removeElement() {
document.getElementById("p1").style.display = "none";
document.getElementById("d1").style.display = "none";
}
function showElement() {
document.getElementById("p1").style.display = "block";
document.getElementById("d1").style.display = "block";
}
</script>
</head>
<body>

<h1>This is a header</h1>
<div id="d1">xxxxxxxxxxxxxxxxxxxxxxxxxx</div>
<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" />
<input type="button" onclick="showElement()" value="display paragraph" />
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: