js滚动条轮播表格 页面刷新后滚动条卡顿一会才往下滚动
<script>
window.onload=function(){
var div = document.querySelector('#hyj');
//定时器
var time = setInterval(function() {
var oldTop = div.scrollTop;
var newTop = oldTop + 1;
div.scrollTop = newTop
// 进行判定是否到底
if (parseInt(div.clientHeight+ div.scrollTop) == div.scrollHeight) {
$('#hyj').animate({scrollTop:0},700);
}
}, 100);
//鼠标放上去
div.onclick=function(){
clearInterval(time);
}
div.onmouseover=function(){
clearInterval(time)
time = setInterval(function() {
var oldTop = div.scrollTop;
var newTop = oldTop + 1;
div.scrollTop = newTop
//进行判定是否到底
if (parseInt(div.clientHeight+ div.scrollTop) == div.scrollHeight) {
//到底了自动往上有动画效果
$('#hyj').animate({scrollTop:0},700);
}
}, 100);
}
}
</script>
<script>
window.onload=function(){
var div = document.querySelector('#hyj');
//定时器
var time = setInterval(function() {
var oldTop = div.scrollTop;
var newTop = oldTop + 1;
div.scrollTop = newTop
// 进行判定是否到底
if (parseInt(div.clientHeight+ div.scrollTop) == div.scrollHeight) {
$('#hyj').animate({scrollTop:0},700);
}
}, 100);
//鼠标放上去
div.onclick=function(){
clearInterval(time);
}
div.onmouseover=function(){
clearInterval(time)
time = setInterval(function() {
var oldTop = div.scrollTop;
var newTop = oldTop + 1;
div.scrollTop = newTop
//进行判定是否到底
if (parseInt(div.clientHeight+ div.scrollTop) == div.scrollHeight) {
//到底了自动往上有动画效果
$('#hyj').animate({scrollTop:0},700);
}
}, 100);
}
}
</script>