
通过JS,将列表实现5秒滚动 10
以下代码要实现将列表实现5秒向上滚动一条,底部滚动到最后一条时返回到第1条继续滚动,初学JS,比较含糊,希望大神帮忙!varhotListDiv=document.get...
以下代码要实现将列表实现5秒向上滚动一条,底部滚动到最后一条时返回到第1条继续滚动,初学JS,比较含糊,希望大神帮忙!
var hotListDiv = document.getElementById("content-right-4-div");
var timer;
function autoPlay() {
console.log(hotListDiv);
timer = setInterval(function () {
if (hotListDiv.style.top == '-700px') {
hotListDiv.style.top = 0;
}
else {
hotListDiv.style.top -= 70;
}
}, 5000);
}
autoPlay() 展开
var hotListDiv = document.getElementById("content-right-4-div");
var timer;
function autoPlay() {
console.log(hotListDiv);
timer = setInterval(function () {
if (hotListDiv.style.top == '-700px') {
hotListDiv.style.top = 0;
}
else {
hotListDiv.style.top -= 70;
}
}, 5000);
}
autoPlay() 展开
展开全部
改成:
var top=parseInt(hotListDiv.style.top);
if (top <=-700) {
hotListDiv.style.top = "0px";
}
else {
hotListDiv.style.top = (top-70)+"px";
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询