温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Jquery 动画-无限循环滚动

发布时间:2020-06-17 16:13:46 来源:网络 阅读:865 作者:1120173856 栏目:web开发

实现功能:

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>

 

 

 

 

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

附件:http://down.51cto.com/data/2362185
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI