JS图片滚动代码解释
我知道每句的意思,我想问的是这个空的demo2存在的意义,为什么要设置它呢?只操作demo1可以做滚动么?为什么要把demo1克隆到demo2里?我要的不是每句话的意思,...
我知道每句的意思,
我想问的是这个空的demo2存在的意义,为什么要设置它呢?只操作demo1可以做滚动么?为什么要把demo1克隆到demo2里?
我要的不是每句话的意思,我想要做这个图片滚动的高屋建瓴的思想,即思考方式。
谢谢高手了
<div id="demo" style="OVERFLOW:hidden; overflow:scroll; COLOR: #ffffff; margin-left:auto; margin-right:auto; width:550px;">
<table cellspacing="0" cellpadding="0" align="left" border="0" cellspace="0">
<tr>
<td id="demo1" valign="top">
<table width="1730" height="16" border="0" align="left" cellpadding="0" cellspacing="0">
<tr align="center">
<td width='170'><a href='http://www.sina.com.cn'><img src='images/dao.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href=''><img src='../images/sy1.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy5.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy4.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy8.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy7.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy5.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy4.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy3.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy9.jpg' width='170' height='100' border='0' /></a></td>
</tr>
</table>
</td>
<td id="demo2" valign="top"></td>
</tr>
</table>
</div>
<SCRIPT>
demo2.innerHTML=demo1.innerHTML
function Marquee()
{
if(demo2.offsetWidth-demo.scrollLeft<=0)
{
demo.scrollLeft-=demo1.offsetWidth
}
else{
demo.scrollLeft++
}
}
var speed=25//速度数值越大速度越慢
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</SCRIPT> 展开
我想问的是这个空的demo2存在的意义,为什么要设置它呢?只操作demo1可以做滚动么?为什么要把demo1克隆到demo2里?
我要的不是每句话的意思,我想要做这个图片滚动的高屋建瓴的思想,即思考方式。
谢谢高手了
<div id="demo" style="OVERFLOW:hidden; overflow:scroll; COLOR: #ffffff; margin-left:auto; margin-right:auto; width:550px;">
<table cellspacing="0" cellpadding="0" align="left" border="0" cellspace="0">
<tr>
<td id="demo1" valign="top">
<table width="1730" height="16" border="0" align="left" cellpadding="0" cellspacing="0">
<tr align="center">
<td width='170'><a href='http://www.sina.com.cn'><img src='images/dao.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href=''><img src='../images/sy1.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy5.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy4.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy8.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy7.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy5.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy4.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy3.jpg' width='170' height='100' border='0' /></a></td>
<td width='170'><a href='#'><img src='../images/sy9.jpg' width='170' height='100' border='0' /></a></td>
</tr>
</table>
</td>
<td id="demo2" valign="top"></td>
</tr>
</table>
</div>
<SCRIPT>
demo2.innerHTML=demo1.innerHTML
function Marquee()
{
if(demo2.offsetWidth-demo.scrollLeft<=0)
{
demo.scrollLeft-=demo1.offsetWidth
}
else{
demo.scrollLeft++
}
}
var speed=25//速度数值越大速度越慢
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</SCRIPT> 展开
2个回答
展开全部
Demo2的用处是在Demo1滚动到边界时后续时使用的,这样的话,可以在Demo1滚动完后显示Demo2的内容,达到不间断滚动目的,如果只有Demo1的话,肯定不行的。^_^
不成熟的说法,
http://www.escdns.com我的站点,可以互想学习一下。
不成熟的说法,
http://www.escdns.com我的站点,可以互想学习一下。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询