gpt4 book ai didi

javascript - onclick,如何隐藏
并显示其后面的内容?

转载 作者:行者123 更新时间:2023-11-28 16:15:27 25 4
gpt4 key购买 nike

我怎样才能做到这个<div>当点击发生在它之外时隐藏自己?我希望能够隐藏它,然后显示其后面页面的其余内容。

<html>
<style>
.overlay
{
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: #fff;
opacity: 0.5;
filter: alpha(opacity=50);
z-index: 80;
}
.popupContent
{
background: #fff;
padding: 5px;
border: 1px solid black;
position: fixed;
top: 100px;
left: 400px;
bottom: 365px;
right: 300px;
z-index: 81;
}​

</style>

<div id="initialPopup">
<div class="overlay"></div>
<div class="popupContent" onclick="hideInitialPopup()">
Good Morning, Please Upload Your File Today!
</div>

</div>




<script>
function hideInitialPopup() {
document.getElementById("initialPopup").style.display = "block";
$("popupContent").mouseup(function(){
if(! mouse_is_inside) $
}​
</script>

</html>

最佳答案

使用 jQuery 的 event.target 来确定您是否在框中单击:

 $(document).on('click',function(e) {
if (!$(e.target).closest('#my_div_id').length) {
$('#my_div_id').hide();
}
});​

http://jsfiddle.net/mblase75/PNYTX/

关于javascript - onclick,如何隐藏 <div> 并显示其后面的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11619774/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com