我創建了一個jQuery動畫,當你點擊其中一個按鈕時,隱藏的div從left: -650px;
滑到left: 0px;
click here to see example但是我注意到當你點擊另一個按鈕來揭示另一個隱藏div時, div不會回到它原來的位置left: -650px;
它留在左邊:0;有沒有人知道我需要添加爲了實現這個...?jquery animate()問題
HTML:
<div id="wrapper">
<div class="top-block">
<ul>
<li><a id="one" href="#" class="proBtn">block</a>
</li>
<li><a id="two" href="#" class="proBtn">test</a>
</li>
<li><a id="three" href="#" class="proBtn">test</a>
</li>
<li><a id="four" href="#" class="proBtn">Lists</a>
</li>
<li><a href="#" class="proBtn">hello</a>
</li>
<li><a href="#" class="proBtn">test</a>
</li>
</ul>
<!-- HOME SECTION -->
<div id="one-bck" class="mid-block fadeInLeft" style="background:green;"></div>
<div id="two-bck" class="mid-block fadeInLeft" style="background:red;"></div>
<div id="three-bck" class="mid-block fadeInLeft"></div>
<div id="four-bck" class="mid-block fadeInLeft"></div>
</div>
</div>
JS
$(document).ready(function() {
$('.proBtn').click(function() {
$('li').removeClass('active');
$('li a').removeClass('blue');
$(this).parent("li").addClass('active');
$(this).addClass('blue');
});
$('#one').click(function() {
$('#two-bck').animate({
left: '-650px;',
opacity: 0
}, 500).removeClass('animated');
$('#three-bck').animate({
left: '-650px;',
opacity: 0
}, 500).removeClass('animated');
$('#four-bck').animate({
left: '-650px;',
opacity: 0
}, 500).removeClass('animated');
$('#one-bck').addClass('animated').animate({
left: '0px',
opacity: 1
}, 500);
});
$('#two').click(function() {
$('#one-bck').animate({
left: '-650px;',
opacity: 0
}, 500).removeClass('animated');
$('#three-bck').animate({
left: '-650px;',
opacity: 0
}, 500).removeClass('animated');
$('#four-bck').animate({
left: '-650px;',
opacity: 0
}, 1500).removeClass('animated');
$('#two-bck').addClass('animated').animate({
left: '0px',
opacity: 1
}, 500);;
});
$('#three').click(function() {
$('#one-bck').animate({
left: '-650px;',
opacity: 0
}, 500).removeClass('animated');
$('#two-bck').animate({
left: '-650px;',
opacity: 0
}, 500).removeClass('animated');
$('#four-bck').animate({
left: '-650px;',
opacity: 0
}, 500).removeClass('animated');
$('#three-bck').addClass('animated').animate({
left: '-650px;',
opacity: 0
}, 500);
});
});
請停止濫用[HTML5]和[CSS3]標籤。 – Pavlo