下面的函数通过获取窗口高度并将其除以窗口高度来计算用户滚动了多远。随着该百分比的增加,我想增加 div 'arrow' 的 css 'height' 数量。我究竟做错了什么?
$(document).scroll(function(){
// grab the scroll amount and the window height
var scrollAmount = $(window).scrollTop();
var documentHeight = $(document).height();
// calculate the percentage the user has scrolled down the page
var scrollPercent = (scrollAmount / documentHeight) * 100;
function increaseHeight() {
$(".arrow").css({
height: scrollPercent + 'px'
});
//do something when a user gets 50% of the way down my page
});