[英]Jquery : Light box closing automatically :(
light box closing automatically with in seconds.灯箱在几秒钟内自动关闭。 Could you help me please
请问你能帮帮我吗
$(document).ready(function(){
$('.lightbox').click(function(){
$('.backdrop, .box').animate({'opacity':'.50'}, 300, 'linear');
$('.box').animate({'opacity':'1.00'}, 300, 'linear');
$('.backdrop, .box').css('display', 'block');
});
$('.close').click(function(){
close_box();
});
$('.backdrop').click(function(){
close_box();
});
});
function close_box()
{
$('.backdrop, .box').animate({'opacity':'0'}, 300, 'linear', function(){
$('.backdrop, .box').css('display', 'none');
});
}
CSS CSS
.backdrop
{
position:absolute;
top:0px;
left:0px;
width:100%;
height:100%;
background:#000;
opacity: .0;
filter:alpha(opacity=0);
z-index:50;
display:none;
}
.box
{
position:absolute;
top:20%;
left:30%;
width:500px;
height:300px;
background:#ffffff;
z-index:51;
padding:10px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow:0px 0px 5px #444444;
-webkit-box-shadow:0px 0px 5px #444444;
box-shadow:0px 0px 5px #444444;
display:none;
}
.close
{
float:right;
margin-right:6px;
cursor:pointer;
}
HTML HTML
<a href="" class="lightbox">Open Lightbox</a>
<div class="backdrop">
<div class="box"><div class="close">x</div>This is the lightbox!!!</div>
</div>
This happens as the form is reloading(Postback happens)... prevent it by adding 'return false' to your code...so your code will be like..这种情况发生在表单重新加载时(回发发生)...通过在代码中添加“return false”来防止它...所以您的代码就像..
$('.lightbox').click(function(){
$('.backdrop, .box').animate({'opacity':'.50'}, 300, 'linear');
$('.box').animate({'opacity':'1.00'}, 300, 'linear');
$('.backdrop, .box').css('display', 'block');
return false;
});
Tyr with this code http://jsfiddle.net/sweetmaanu/yx6W3/ Tyr 这个代码http://jsfiddle.net/sweetmaanu/yx6W3/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.