Javascript 如何在卷轴上加载div
当jquery发生滚动事件时,如何加载div及其子元素 例如,我只想在用户滚动时加载这个div和这个div内的内容Javascript 如何在卷轴上加载div,javascript,jquery,performance,Javascript,Jquery,Performance,当jquery发生滚动事件时,如何加载div及其子元素 例如,我只想在用户滚动时加载这个div和这个div内的内容 <div id="loadonscroll"> //some images and scripts inside this div need to be load on scroll </div> 这对我有用。滚动时,数据将附加在DIV标记上。滚动后应显示 $(window).scroll(function() { if($(window).
<div id="loadonscroll">
//some images and scripts inside this div need to be load on scroll
</div>
这对我有用。滚动时,数据将附加在DIV标记上。滚动后应显示
$(window).scroll(function() {
if($(window).scrollTop() == $(document).height() - $(window).height()) {
// ajax call and append data on DIV
$("#loadonscroll").html(ajaxData);
}
});
//滚动到按钮
$window.scroll函数{
如果$window.scrollTop+$window.height==$document.height{
var data=html代码
$loadonscroll.htmldata;
}
};
//接近底部!
$window.scroll函数{
如果$window.scrollTop+$window.height>$document.height-100{
var data=html代码
$loadonscroll.htmldata;
}
};这个问题已经有了很好的教程/答案,在发布一个问题时,你还应该告诉我们你尝试了什么以及在哪里遇到了问题。这是一把小提琴,不是我的,有很多例子。这回答了你的问题吗?你能给上面的例子编码吗?