JS实现div内部的文字或图片自动循环滚动代码

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

JS实现div内部的文字或图片自动循环滚动代码

  2020-05-13 我要评论
复制代码 代码如下:

<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

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们