jquery 頁首單行資訊滾動顯示實現思路及代碼

來源:互聯網
上載者:User

以下是控制滾動的樣式,將滾動的內容查詢出來,放在一個div 或者別的容器裡面,我這裡使用的是<dt>

<style>#newCglist{width:300px;height:14px;line-height:14px;overflow:hidden}#newCglist li{height:14px;padding-left:10px;}</style>

以下是滾動內容展示的容器

<dt class="positionrel" id="newCglist" ><div class="new positionabs"></div></dt>

以下是js,查詢滾動展示內容

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);});});

以下是控制滾動展示時間,以及樣式

/*** 首頁頂部滾動效果,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);});}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.