一段滚动文字的js (jQuery)
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(); });
在原来的一直滚动稍微改了一下,每滚动一条之后停一会儿。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。