javaScript 无间隔滚动 求代码,解决立马给分! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <div id="demo" style="overflow:hidden;height:210;width:560;color:#ffffff"> <table align="left" cellpadding="0" cellspace="0" border="0"> <tr> <td id="demo1" valign="top"><table border="0" cellpadding="0" cellspacing="0"> <tr> <td><img src="indexgd/001.gif" width="143" height="200" /></td> <td><img src="indexgd/002.gif" width="143" height="200" /></td> <td><img src="indexgd/003.gif" width="143" height="200" /></td> <td><img src="indexgd/004.gif" width="143" height="200" /></td> <td><img src="indexgd/005.gif" width="143" height="200" /></td> <td><img src="indexgd/006.gif" width="143" height="200" /></td> <td><img src="indexgd/007.gif" width="143" height="200" /></td> <td><img src="indexgd/008.gif" width="143" height="200" /></td> </tr> </table></td> <td id="demo2" valign="top"></td> </tr> </table></div><script> var speed=8//速度数值越大速度越慢 document.getElementById("demo2").innerHTML=document.getElementById("demo1").innerHTML function Marquee(){ if(document.getElementById("demo2").offsetWidth-document.getElementById("demo").scrollLeft<=0) document.getElementById("demo").scrollLeft-=document.getElementById("demo1").offsetWidth else{ document.getElementById("demo").scrollLeft++ } } var MyMar=setInterval(Marquee,speed) demo.onmouseover=function(){clearInterval(MyMar)} demo.onmouseout=function(){MyMar=setInterval(Marquee,speed)}</script> Jquery实现:使用之前,先插入 jQuery 框架( 直接从 Google 拿 ):<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>JS 代码( 以 <script type="text/javascript"></script> 包裹,或者保存成单独文件引用。):$(document).ready(function(){$("#sItem li:not(:first)").css("display","none");var B=$("#sItem li:last");var C=$("#sItem li:first");setInterval(function(){if(B.is(":visible")){C.fadeIn(500).addClass("in");B.hide()}else{$("#sItem li:visible").addClass("in");$("#sItem li.in").next().fadeIn(500);$("li.in").hide().removeClass("in")}},3000) //每3秒钟切换一条,你可以根据需要更改})HTML 部分:<ul id="sItem"><li>文字或图片</li><li>文字或图片</li><li>文字或图片</li></ul>条目不限,内容不限,将需要循环滚动展示的条目放置于 <ul id="sItem"> 中就可以了 function Marquee(){ if(document.getElementById("demo2").offsetTop-document.getElementById("demo").scrollTop<=0) document.getElementById("demo").scrollTop-=document.getElementById("demo1").offsetHeight else{ document.getElementById("demo").scrollTop++ } }向上 如何用js写一个自己的脚本插件(jquery) 怎么在对象中再声明一个对象 ie 下 有没有办法监听到disabled的改变 脚本问题 关于JS取得元素位置的问题 诚心请教图片加载的问题!!!!!急急急!!!!! js求当前时间出错 如何获取datagrid中input元素的值 fso创建 报Automation服务器不能创建 错误 怎么把json格式的假数组转成真数组呢 经典老问题 困惑死多少新人 点击弹出层的问题
<table align="left" cellpadding="0" cellspace="0" border="0">
<tr>
<td id="demo1" valign="top"><table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="indexgd/001.gif" width="143" height="200" /></td>
<td><img src="indexgd/002.gif" width="143" height="200" /></td>
<td><img src="indexgd/003.gif" width="143" height="200" /></td>
<td><img src="indexgd/004.gif" width="143" height="200" /></td>
<td><img src="indexgd/005.gif" width="143" height="200" /></td>
<td><img src="indexgd/006.gif" width="143" height="200" /></td>
<td><img src="indexgd/007.gif" width="143" height="200" /></td>
<td><img src="indexgd/008.gif" width="143" height="200" /></td>
</tr>
</table></td>
<td id="demo2" valign="top"></td>
</tr>
</table>
</div>
<script>
var speed=8//速度数值越大速度越慢
document.getElementById("demo2").innerHTML=document.getElementById("demo1").innerHTML
function Marquee(){
if(document.getElementById("demo2").offsetWidth-document.getElementById("demo").scrollLeft<=0)
document.getElementById("demo").scrollLeft-=document.getElementById("demo1").offsetWidth
else{
document.getElementById("demo").scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function(){clearInterval(MyMar)}
demo.onmouseout=function(){MyMar=setInterval(Marquee,speed)}
</script>
使用之前,先插入 jQuery 框架( 直接从 Google 拿 ):<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery
/1.2.6/jquery.min.js"></script>
JS 代码( 以 <script type="text/javascript"></script> 包裹,或者保存成单独文件引用。):$(document).ready(function(){
$("#sItem li:not(:first)").css("display","none");
var B=$("#sItem li:last");
var C=$("#sItem li:first");
setInterval(function(){
if(B.is(":visible")){
C.fadeIn(500).addClass("in");B.hide()
}else{
$("#sItem li:visible").addClass("in");
$("#sItem li.in").next().fadeIn(500);
$("li.in").hide().removeClass("in")}
},3000) //每3秒钟切换一条,你可以根据需要更改
})
HTML 部分:<ul id="sItem">
<li>文字或图片</li>
<li>文字或图片</li>
<li>文字或图片</li>
</ul>
条目不限,内容不限,将需要循环滚动展示的条目放置于 <ul id="sItem"> 中就可以了
function Marquee(){
if(document.getElementById("demo2").offsetTop-document.getElementById("demo").scrollTop<=0)
document.getElementById("demo").scrollTop-=document.getElementById("demo1").offsetHeight
else{
document.getElementById("demo").scrollTop++
}
}向上