【发布时间】:2019-09-25 08:44:43
【问题描述】:
元素的#2 id 仅在向下滚动后加载,因为我无法使用getElementById("#2") 获取它。
//JS代码
$(document).ready(function() {
$('html, body').animate({
scrollTop: $("#2").offset().top
}, 'slow');
});
// waypoint code:
var infinite = new Waypoint.Infinite({
element: $('.infinite-container')[0],
context: document.getElementById('#16'),
onBeforePageLoad: function() {
$('.loading').show();
},
onAfterPageLoad: function($items) {
$('.loading').hide();
}
});
示例: 在页面加载时只显示 1,6,3,4,5
1
6
3
4
5
向下滚动后,我只得到 2,
2
我想在第一次加载年龄时直接滚动到'2'元素。
【问题讨论】:
-
根本不清楚您要做什么或问题出在哪里。您能否编辑问题以提供更多详细信息。
-
@RoryMcCrossan 现在知道了吗?
标签: javascript python jquery jquery-waypoints waypoint