使 jquery 切换 div 仅在我单击退出按钮时关闭
making a jquery toggle div only toggle off when i click a exit button
所以我使用 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
的里面,一旦.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>
所以我使用 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
的里面,一旦.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>