【发布时间】:2018-09-11 07:48:57
【问题描述】:
我是following this example 来创建一段文本,单击该文本会展开/折叠文本。
如何将初始值设置为隐藏,使段落最初折叠,点击时展开?
下面是代码。
div#expand {
width: 500px
display:none;
}
<html lang="en">
<head>
<meta charset="utf-8">
<script>
function show() {
if (document.getElementById('expand').style.display == 'none')
document.getElementById('expand').style.display = 'block';
else
document.getElementById('expand').style.display = 'none';
}
</script>
</head>
<body>
<p>
<a href="javascript:;" onclick=show()>About Us</a>
<div id="expand">
<p>this is all about us. <br></p>
</div>
</p>
</body>
</html>
【问题讨论】:
标签: javascript html css collapse