我有一種類型的進度跟蹤器坐在我的頁面一側,當您滾動時,我希望線條獲得高度(百分比),當用戶向下滾動頁。我無法在用戶滾動時讓高度增加一個。這是我目前的代碼。如何在窗口滾動上增加數字1在窗口滾動上
JS
$(window).scroll(function(){
var number = 0; /* I'd like to increment this by one on scroll */
// Only start the process when the first section comes into view
if($("#progress-tracker-nav li").hasClass('active-section')) {
number++; /* I'd like to increment this by one on scroll */
$(".progress-line").css('height', number + '%');
}
})
你不應該使用的滾動功能1計數器,因爲你必須考慮到,當他們向上滾動以及 –