스크롤 막대의 끝부분을 판단하고,

2322 단어 스크롤 바

$(document).ready(function() {
$(window).scroll(function() {
reachBottom();
});
});
function reachBottom() {
var scrollTop = 0;
var clientHeight = 0;
var scrollHeight = 0;
if (document.documentElement && document.documentElement.scrollTop) {
scrollTop = document.documentElement.scrollTop;
} else if (document.body) {
scrollTop = document.body.scrollTop;
}
if (document.body.clientHeight && document.documentElement.clientHeight) {
clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight;
} else {
clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight;
}
scrollHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
if (scrollTop + clientHeight == scrollHeight) {
// return true;
$("#test").fadeIn();
} else {
//return false;
$("#test").fadeOut();
}
}

좋은 웹페이지 즐겨찾기