滚动顶部slimscroll插件 [英] Scroll top with slimscroll plugin
问题描述
我用 slimScroll
在我的网页与由AJAX添加的内容。
I used slimScroll
on my web page with the content is added by AJAX.
如果我向下滚动,滚动然后重新用更多的内容(AJAX负载),滚动条本身始终保持其位置和以前一样。
If I scroll down the scroll then reload with more content (AJAX load), the scroll bar itself always keep its position the same as before.
我不知道 slimScroll
有,我可以打电话滚动到顶部加载新内容之后的任何功能?
I wonder if the slimScroll
has any function that I can call to scroll to top after loading the new content?
推荐答案
我不认为滚动
通过@rochal描述的选项是去工作,现在,作为它似乎并没有被版本目前最多在GitHub上。相反,尝试 scrollTo
或 scrollBy
。
I don't think the scroll
option described by @rochal is going to work right now, as it doesn't appear to be used by the version currently up on GitHub. Instead try scrollTo
or scrollBy
.
要滚动到顶部:
$('#elem_id').slimScroll({ scrollTo : '0px' });
相反,如果你想滚动至底部,那么下面应该工作:
Conversely, if you want to scroll to the bottom, then the following should work:
var scrollTo_val = $('#elem_id').prop('scrollHeight') + 'px';
$('#elem_id').slimScroll({ scrollTo : scrollTo_val });
这篇关于滚动顶部slimscroll插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!