實現功能:css
一、當點擊按鈕的時,元素切換,切換到最後一個時,會自動切換回第一個,而後繼續循環切換!app
Jquery代碼:ide
$(document).ready(function(){this
$("#bb").click(function(){spa
$(".scroll ul").animate({ip
marginRight:"-25px"input
},100,function(){it
$(this).css({marginRight:"0px"}).find("li:first").appendTo(this);io
}); function
});
});
</script>
HTML代碼:
<body>
<div class="scroll">
<ul>
<li style="background-color:#0F0">1</li>
<li style="background-color:#930">2</li>
<li style="background-color:#393">3</li>
<li style="background-color:#9C6">4</li>
<li style="background-color:#F99;">5</li>
</ul>
</div>
<input type="button" id="bb" value="向右" />
</body>
CSS代碼:
<style type="text/css">
<!--
.scroll ul {
margin: 0px;
list-style-type: none;
padding: 0px;
}
.scroll ul li {
height: 50px;
width: 50px;
float: left;
display: block;
line-height: 50px;
text-align: center;
}
.scroll {
float: left;
width: 50px;
height: 50px;
overflow: hidden;
}
-->
</style>
-----上傳了源文件,有須要的本身下載下來看看吧!