图片跑马灯不连续的问题解析
<div id="demo1">
<img src="xxx.jpg">
<img src="xxx.jpg">
<img src="xxx.jpg">
<img src="xxx.jpg">
<img src="xxx.jpg">
<img src="xxx.jpg">
</div>
<div id="demo2"></div>
</div>
<script language="javascript" type="text/javascript">
<!--
var demo = document.getElementById("demo");
var demo1 = document.getElementById("demo1");
var demo2 = document.getElementById("demo2");
var speed = 10; //滚动速度值,值越大速度越慢
demo2.innerHTML = demo1.innerHTML;//克隆demo2为demo1
function Marquee(){
??? ??? if(demo2.offsetWidth-demo.scrollLeft<=0){
??? ??? ??? demo.scrollLeft-=demo1.offsetWidth;
??? ??? }else{
??? ??? ??? demo.scrollLeft++;
??? ??? ???
??? ??? }
??? }
var MyMar = setInterval(Marquee, speed); //设置定时器
demo.onmouseover = function() {
?clearInterval(MyMar);
} //鼠标经过时清除定时器达到滚动停止的目的
demo.onmouseout = function() {
?MyMar = setInterval(Marquee, speed);
} //鼠标移开时重设定时器
-->
</script>