Home >Web Front-end >JS Tutorial >jquery header single line information scrolling display implementation ideas and code_jquery
The following is the style to control scrolling. Query the scrolling content and put it in a div or other container. What I use here is 73de882deff7a050a357292d0a1fca94
<style> #newCglist{width:300px;height:14px;line-height:14px;overflow:hidden} #newCglist li{height:14px;padding-left:10px;} </style>
The following is a container for scrolling content display
<dt class="positionrel" id="newCglist" ><div class="new positionabs"></div></dt>
The following is js to query the scrolling display content
var divhight ; //这是所有数据行的高度,每行行高*数据量 var showtimes ; //显示完所有数据的时间,每行显示所需的时间*数据量
function yejis(){ setInterval('AutoScroll("#newCglist")',500); //最新成交案例展示 $.post("zrAction!newCgList.action",null,function(data){ divhight = data.length*14; showtimes = data.length*3000; $.each(data,function(i,datas){ $ul = $("<ul></ul>"); $tr = $("<li>"+datas[0]+" 签单成功! "+datas[1]+"元 "+datas[2]+" "+datas[3]+"</li>"); $ul.append($tr); $("#newCglist").append($ul); }); });
The following is to control the scrolling display time and style
/** * 首页顶部滚动效果,divhight 是所有数据的行高 * showtimes //循环滚动完这些数据所需的时间 * @param {Object} obj * @memberOf {TypeName} */ function AutoScroll(obj){ $(obj).find("ul:first").animate({ marginTop:-divhight },showtimes,function(){ $(this).css({marginTop:"0px"}).find("li:first").appendTo(this); }); }