我想我可能缺乏对 div 关系的理解?
最终,目标是使“元素” div 在蓝色“父” div 的顶部向下滑动。
但是当前的重点是简单地使其显示(显示最初设置为“无”)。
我不确定为什么这不起作用...
<style type="text/css">
#parent {
height: 100px;
width: 100px;
background-color: blue;
}
#element {
height: 50px;
width: 50px;
background-color: red;
display: none;
}
</style>
<body>
<div id="element"></div>
<div id="parent" onclick="peekDown('element');"> </div>
</body>
<script type="text/javascript">
//<![CDATA[
function peekDown(id) {
var element = document.getElementById(id);
element.style.display = "";
console.log(element.style.display);
}
//]]>
</script>