인프런 커뮤니티 질문&답변
질문드립니다~
작성
·
271
1
안녕하세요 ~ 제가 초보라 궁금한게 있어서요
$(window).scroll(function(){
getPercent();
})
function init(){
getPercent();
}
init();
getPercent(); 이 함수가 왜 두번이나 실행되는거죠 ?
퀴즈
스크롤된 거리를 백분율로 나타내는 올바른 계산식은 무엇일까요? (scrollTop: 현재 스크롤 위치, documentHeight: 문서 전체 높이, windowHeight: 화면 높이)
(scrollTop / documentHeight) * 100
(scrollTop / (documentHeight - windowHeight)) * 100
(windowHeight / documentHeight) * 100
(documentHeight - scrollTop) / windowHeight * 100




