gpt4 book ai didi

jquery - 使 jquery 切换 div 仅在我单击退出按钮时切换

转载 作者:太空宇宙 更新时间:2023-11-04 09:21:13 24 4
gpt4 key购买 nike

所以我使用 slidetoggle(); 打开和关闭一个 div;在 jquery 中,但每次我单击屏幕上的任意位置时,它都会切换回关闭状态 here是网站

这是我正在使用的代码

jquery

    jQuery(document).ready(function(){
firstLoad();

$('#a1').live('click', function(event) {
toggleFoodDiv();
});

$('#a2').live('click', function(event) {
toggleLazerTagDiv();
});

function toggleFoodDiv(){
$('#food-div').slideToggle("fast");
}
function toggleLazerTagDiv(){
$('#lazertag-div').slideToggle("fast");
}
});
//both of those divs use the .information class

CSS

.information{
z-index: 2;
top:60px;
left:0px;
position:fixed;
width:100%;
height:100%;
background:#2c3e50;
opacity: 0.9;
filter: Alpha(opacity=90);
}

最佳答案

<div class="row-img" id="a1">
<div id="food-div" class="information" style="display: none;">
<h2 class="info-h2">We Serve food Too!</h2>
</div>
</div>

因为#food-div#a1里面,所以整个屏幕都被#a1填满了一旦 .information div 可见。

只需拉出 .information div。

<div class="row-img" id="a1"></div>
<div id="food-div" class="information" style="display: none;">
<h2 class="info-h2">We Serve food Too!</h2>
</div>

关于jquery - 使 jquery 切换 div 仅在我单击退出按钮时切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41474693/

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