on-internet
← Community

$(window).scroll function is not working on mobile

Stack Overflow ·

I am using a $(window).scroll event triggered function on my website, all is well only that it doesn't work on mobile devices. This is the code I am using: $(window).scroll(function(){ var wh = $(window).height(); var scrolledFromtop = $(window).scrollTop(); if( scrolledFromtop > wh ){ $('html').addClass('scrolled'); }else{ $('html').removeClass('scrolled'); } }); I also tried this code but with no success: document.addEventListener("touchmove",aaa, false); function aaa(){ var wh = $(window).height(); var scrolledFromtop = $(window).scrollTop(); if( scrolledFromtop > (wh) ){ $('html').addClass

Comments

Sign in or sign up to comment and upvote.

No comments yet.