简体   繁体   English

jQuery Mobile中的自动滚动功能

[英]Auto scroll function in jquery mobile

Hi I am trying to implement a autoscroll function on my webapp. 嗨,我正在尝试在我的Web应用程序上实现自动滚动功能。 After page load the page should scroll automatically to the bottom without an animation. 页面加载后,页面应自动滚动到底部而没有动画。 I need it for a little chat application where after page loading the latest list item s should become displayed. 我需要一个小的聊天应用程序,在页面加载后,应该显示最新list item I created a fiddle . 我制造了一个小提琴

// this version wont work:
myscroll = $('#chatOutput');
myscroll.scrollTop(myscroll.get(0).scrollHeight);
//this wont work too:
$(document).scrollTop($(document).height());

What am I doing wrong? 我究竟做错了什么?

Please try this 请尝试这个

   $(window).load(function() {

    setTimeout(function(){ 

    $(document).scrollTop($('.chatPost:last-child').offset().top);

    }, 1000);
   });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM