实现功能:

1、当点击按钮的时,元素切换,切换到最后一个时,会自动切换回第一个,然后继续循环切换!

Jquery代码:

 

 

$(document).ready(function(){

$("#bb").click(function(){

$(".scroll ul").animate({

marginRight:"-25px"

},100,function(){

$(this).css({marginRight:"0px"}).find("li:first").appendTo(this);

});  

});

});

</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>

 

 

 

 

-----上传了源文件,有需要的自己下载下来看看吧!