function startmarqueeOneSMS() { var t; var to; var ishover = false; var waitone = 3000; var speed = 30; var currentI = 0; var stop_margintop = {}; var o = document.getElementById("demo2"); var maxI = jQuery("div", o).length; var tempmargintop = 0; jQuery("div", o).each(function(index) { tempmargintop += jQuery(this).outerHeight(); stop_margintop[index] = tempmargintop; }); //复制一份避免出现空白 o.innerHTML += o.innerHTML; o.style.marginTop = "0px"; function start() { clearInterval(t); clearTimeout(to); t = setInterval(scrolling, speed); //document.getElementById("kw").value = new Date().getSeconds(); } o.onmouseover = function() { clearInterval(t); clearTimeout(to); } o.onmouseout = function() { start(); } function scrolling() { var margintop = parseInt(o.style.marginTop); if (stop_margintop[currentI] == Math.abs(margintop)) { clearInterval(t); currentI++; if (currentI == maxI) { o.style.marginTop = "0px"; currentI = 0; } to=setTimeout(start, waitone); } else { //向上滚动1PX o.style.marginTop = parseInt(margintop) - 1 + "px"; } } start(); } startmarqueeOneSMS(); });
在原来的一直滚动稍微改了一下,每滚动一条之后停一会儿。
时间: 2024-10-24 00:39:22