【发布时间】:2013-11-11 09:13:58
【问题描述】:
我想用 JavaScript 显示和隐藏一个 div。 有人有额外的代码吗?到目前为止,这是我的代码:
<script>
window.onload=function(){$hide.div(div)};
</script>
HTML:
<div class="overlay"></div>
<div class="modal">I'm the modal window!</div>
CSS:
.overlay {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: rgba(0,0,0,0.5);
z-index: 10;
}
.modal {
width: 300px;
height: 200px;
line-height: 200px;
position: fixed;
top: 50%;
left: 50%;
margin-top: -100px;
margin-left: -150px;
background-color: #f1c40f;
border-radius: 5px;
text-align: center;
z-index: 11;
}
【问题讨论】:
-
$hide定义在哪里? -
至少有3个例子说明如何做到这一点->
-
Google 和 StackOverflow 上有很多很多关于如何使用 javascript 显示和隐藏 div 以及如何进行模态对话的示例。看看api.jquery.com/hide的初学者...
标签: javascript