jQuery animate를 항상 사용하지만 이번에는 어떤 이유로 실패합니다. 그것은 그것을 작동합니다 closeBtn 클릭 후 '$ (this) .animate'를 타겟팅하려고하면 작동합니다. 여기 jQuery 애니메이션이 작동하지 않는 이유는 무엇입니까?
내 HTML의 일부입니다합니다 (relivant 부품, 그래 내가 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;
}
그 ID는 한 번만 사용하셨습니까? – adeneo
console.log ("test")를 사용해 보셨습니까? 다양한 단계를 거쳐 코드가 어떤 줄을 나누고 있는지 확인하십시오. 또는 오류가 있는지 확인하기 위해 콘솔을 살펴 보셨습니까? – ntgCleaner
이와 같은 경우 jsfiddle도 만들어야합니다. 우리의 삶을 편하게 해줍니다. – user1048676