我一直使用 jQuery animate,但这次由于某种原因失败了。它将起作用,我尝试在 closeBtn 单击后定位“$(this).animate”,它会起作用,有点。
这是我的 html 的一部分(相关部分,是的,我已经调用了 jQuery 库)
<div id='lightBox' style="opacity:0;">
<div id='closeBtn'>
</div>
<div id='lightBoxContent'>
</div><!--lightBoxContent-->
</div><!--lightBox-->
这是我的jQuery
$(document).ready(function()
{
$('#quoteBtn').click(function()
{
$('#lightBox').animate({
opacity:'1',
height:'560px'
}, 300, function() {
$('#lightBoxContent').html(output);
});
$('#closeBtn').click(function()
{
//alert('click');
$('#lightBox').animate({
opacity:'0'
}, 300, function() {
//alert('first animation complete');
$('#lightBox').animate({
height:'0px'
}, 300, function() {
//alert('second animation complete');
});
});
});
});
});
和我的css(这并不是真正的要求,但为了安全起见,我将其包括在内
#lightBox {
width:780px;
background-color:white;
position:fixed;
margin-left:-400px;
margin-top:-300px;
left:50%;
top:50%;
z-index:9999;
-webkit-box-shadow: 0px 0px 200px 50px ;
box-shadow: 0px 0px 200px 50px ;
padding:20px;
}