jsp写了新闻模块,新闻数据是从mysql中取出来的,我想把新闻这一块儿做成循环滚动的效果,求具体代码
以下代码提供参考
<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</dt>
</dl>
<dl>
<dt>测试数据2</dt>
</dl>
<dl>
<dt>测试数据3</dt>
</dl>
<dl>
<dt>测试数据4</dt>
</dl>
<dl>
<dt>测试数据5</dt>
</dl>
<dl>
<dt>测试数据6</dt>
</dl>
<dl>
<dt>测试数据7</dt>
</dl>
<dl>
<dt>测试数据8</dt>
</dl>
<dl>
<dt>测试数据9</dt>
</dl>
<dl>
<dt>测试数据10</dt>
</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>
请看我补充的问题,我看不懂jquery
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>分别用marquee和div+js实现首尾相连循环滚动效果</TITLE>
<style>
#news{
border:1px solid #999999;
width:100px;
height:180px;
display:inline;
}
</style>
</HEAD>
<BODY>
用DIV+javascript实现首尾相连循环滚动效果(兼容firefox):<br /><br />
<DIV id="scrollobj" style="white-space:nowrap;overflow:hidden;width:955px;height:200px;padding:3px;">
<div id="news">123</div>
<div id="news">456</div>
<div id="news">789</div>
</DIV>
<script language="javascript" type="text/javascript">
<!--
function scroll(obj) {
var tmp = (obj.scrollLeft)++;
//当滚动条到达右边顶端时
if (obj.scrollLeft==tmp) obj.innerHTML += obj.innerHTML;
//当滚动条滚动了初始内容的宽度时滚动条回到最左端 (此处可以根据需要选择是否注释)
if (obj.scrollLeft>=obj.firstChild.offsetWidth) obj.scrollLeft=0;
}
setInterval("scroll(document.getElementById('scrollobj'))",50);
//-->
</script>
</BODY>
</HTML>