有人可以請看看這個,並告訴我我做錯了什麼。這是與點擊.content-wrapper
元素將移動和.move.up
WIL改變類名.move.dwn
類move.up跨度後,move.dwn.click(function()
應該開始,但我永遠不能使它到這一點,爲什麼呢?jQuery動畫改變多個類名不工作
<style type="text/css">
.content-wrapper {
height:100px;
width:100px;
background-color:orange;
position:relative;
}
span.move {
background-color:fuchsia;
cursor:pointer;
}
</style>
<span class="move up">click here</span>
<div class="content-wrapper"></div>
<script type="text/javascript">
$(document).ready(function() {
$('.move.up').click(function() {
alert("up");
$('.content-wrapper').animate({'left': '+=568px'}, 'slow');
$(this).removeClass('up');
$(this).addClass('dwn');
});
$('.move.dwn').click(function() {
alert("dwn");
$('.content-wrapper').animate({'left': '-=568px'}, 'slow');
$(this).removeClass('dwn');
$(this).addClass('up');
});
});
</script>
看到這個http://api.jqueryui.com/switchClass/ – Shathish