i have this js code for when user scroll reach 0px of bottom, something happen:
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
console.log("ok");
$( ".more" ).trigger( "click" );
}
});
but when i want that event occurred when user scroll distance of bootm equal to 100px,js code doesn't work, here is that code doesn't work:
$(window).scroll(function() {
var scroll = ($(document).height())-100;
if($(window).scrollTop() + $(window).height() == scroll) {
console.log("ok");
$( ".more" ).trigger( "click" );
}
});
Try by updating code as below:
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
console.log("ok");
$( ".more" ).trigger( "click" );
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.