JS实现div内部的文字或图片自动循环滚动代码
人气:2复制代码 代码如下:
<style type="text/css">
.content{width:500px;height:300px;position:absolute;left:200px;top:100px;border:solid 2px red;padding:10px;overflow:hidden}
dl{width:400px;height:30px;border:1px solid black;}
</style>
<div class="content">
<dl>
<dt>测试数据1<https://img.qb5200.com/download-x/dt>
<https://img.qb5200.com/download-x/dl>
<dl>
<dt>测试数据2<https://img.qb5200.com/download-x/dt>
<https://img.qb5200.com/download-x/dl>
<dl>
<dt>测试数据3<https://img.qb5200.com/download-x/dt>
<https://img.qb5200.com/download-x/dl>
<dl>
<dt>测试数据4<https://img.qb5200.com/download-x/dt>
<https://img.qb5200.com/download-x/dl>
<dl>
<dt>测试数据5<https://img.qb5200.com/download-x/dt>
<https://img.qb5200.com/download-x/dl>
<dl>
<dt>测试数据6<https://img.qb5200.com/download-x/dt>
<https://img.qb5200.com/download-x/dl>
<dl>
<dt>测试数据7<https://img.qb5200.com/download-x/dt>
<https://img.qb5200.com/download-x/dl>
<dl>
<dt>测试数据8<https://img.qb5200.com/download-x/dt>
<https://img.qb5200.com/download-x/dl>
<dl>
<dt>测试数据9<https://img.qb5200.com/download-x/dt>
<https://img.qb5200.com/download-x/dl>
<dl>
<dt>测试数据10<https://img.qb5200.com/download-x/dt>
<https://img.qb5200.com/download-x/dl>
</div>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function(){
$('.content dl').hide();
$('.content dl:gt('+($('.content dl').length - 5)+')').show();
window.setInterval(function(){
$('.content dl:visible:first').prev().slideDown("fast",function(){
$(this).animate({opacity:1},2000,function(){
if($('.content dl:hidden').length == 0){
$('.content dl').hide();
$('.content dl:gt('+($('.content dl').length - 5)+')').show();
}
});
});
},1000);
});
</script>
代码演示地址:
http://www.nailyo.com/js_demo/gundong.html
加载全部内容