越来越快是setInterval的问题,可以加个定时器去,可以参考我的js
setInterval(function(){
$("div[widgetname=REPORT12]").find("tbody").children().eq(1).children().eq(1).children().css({"overflow-x":"hidden","overflow-y":"hidden"});
$("div[widgetname=REPORT12]").find("tbody").children().eq(0).children().eq(1).children().css({"overflow-x":"hidden","overflow-y":"hidden"})
}, 0);//重复运行的间隔时间
window.flag2 = true;
//鼠标悬停,滚动停止
setInterval(function() {
$("div[widgetname=REPORT12]").find(".frozen-center").mouseover(function() {
window.flag2 = false;
});
//鼠标离开,继续滚动
$("div[widgetname=REPORT12]").find(".frozen-center").mouseleave(function() {
window.flag2 = true;
});
var old = -1;
// 清除定时器
if(window.tag2!=null){
window.clearInterval(window.tag2);
}
//调用定时器
window.tag2 = setInterval(function() {
if(window.flag2) {
currentpos = $("div[widgetname=REPORT12]").find(".frozen-center")[0].scrollTop;
if(currentpos == old) {
$("div[widgetname=REPORT12]").find(".frozen-center")[0].scrollTop = 0;
} else {
old = currentpos;
//以100ms的速度每次滚动1.5PX
$("div[widgetname=REPORT12]").find(".frozen-center")[0].scrollTop = currentpos + 1.5;
}
}
}, 100);
}, 1000);