js学习笔记之公告逐行显示
$(function(){ var newsListHeight = $(".news-list").height(); //获得内容的高度 var newsConHeight = $(".news-con").innerHeight();//获得外层的高度 var rows = 1;//初始化当前行为第一行 setInterval(function(){ var nowtop = - rows * newsConHeight; $(".news-list").css("top",nowtop); rows++ if(rows * newsConHeight >= newsListHeight){ rows = 0;} },3000); });