上下无缝滚动
注意点父级元素高度与第一个子元素高度相同才可无限滚动。
function scroll_table() {
var speed = 10;
table2.innerHTML = table1.innerHTML;
function Marquee() {
if (table1.offsetTop - table.scrollTop <= 0) {
table.scrollTop -= table1.offsetHeight;
} else {
table.scrollTop++;
}
}
var MyMar = setInterval(Marquee, speed);
table.onmouseover = function() {
clearInterval(MyMar);
}
table.onmouseout = function() {
MyMar = setInterval(Marquee, speed);
}
}
var speed = 10;
table2.innerHTML = table1.innerHTML;
function Marquee() {
if (table1.offsetTop - table.scrollTop <= 0) {
table.scrollTop -= table1.offsetHeight;
} else {
table.scrollTop++;
}
}
var MyMar = setInterval(Marquee, speed);
table.onmouseover = function() {
clearInterval(MyMar);
}
table.onmouseout = function() {
MyMar = setInterval(Marquee, speed);
}
}