新闻滚动小案例:
把第一个放在最后的位置
此代码重点:list.appendChild(list.children[0]);
js部分:
var view = document.getElementById("view");
var list = document.getElementById("list");
function nextPage(){
$_animation(list,"marginTop",-50,400,function(){
list.style.marginTop = 0;
// 把第一个放在最后的位置
list.appendChild(list.children[0]);
list.children[0].style.color = "green";
list.children[0].style.fontFamily = "楷体";
list.children[0].style.fontSize = "18px";
})
}
var timer = setInterval(nextPage,1000);
view.onmouseover = function(){
clearInterval(timer);
}
view.onmouseout = function(){
timer = setInterval(nextPage,1000);
}
div部分:
<button id="next">下一条</button