我在得到一個功能與動畫到第二/關閉點擊工作的問題。它適用於第一次點擊,但...下面的代碼:jQuery的父動畫第二次點擊(關閉/回滾)不工作
HTML:
<div id="about">
<div id="aboutbtn-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>
<div id="aboutbtn">About me</div>
<div class="social-icons">
<a href="#"><img src="http://placehold.it/43x43"></a>
<a href="#"><img src="http://placehold.it/43x43"></a>
</div>
</div>
CSS:
#about {
background: #336699;
height: 561px;
width: 300px;
position:absolute;
top: 0%;
right:-285px;
}
#aboutbtn {
background: #336699;
background-size: contain;
background-repeat: no-repeat;
width: 85px;
height: 35px;
text-align: center;
padding: 35px 10px;
font-size: 18px;
cursor: pointer;
color: #fff;
position: absolute;
left: -85px;
margin-top: 20px;
margin-right: 15px;
display: block !important;
}
#aboutbtn-content {
float: left;
padding: 35px 30px;
}
.social-icons {
position: absolute;
left: -63px;
top: 140px;
}
.social-icons img {
display: block;
margin-bottom: 10px;
}
的Javascript:
$(document).ready(function() {
$("#aboutbtn").click(function() {
$(this).parent().animate({
right: '-280px'
}, {
queue: false,
duration: 500
});
}, function() {
$(this).parent().animate({
right: '0px'
}, {
queue: false,
duration: 500
});
});
});
我已經做出了jsfiddle you can see by clicking here 。
我得到了靈感from this fiddle,唯一不同的是我改變它切換到點擊。
我不是最清晰的JS編碼器,所以請多多包涵:d。我會感謝任何答案!
在此先感謝!