Jquery if windows scroll. So, you are dealing with a webpage which needs on-scroll function, when a user scrolls the page to some extent, so the content, color or something else should change on the page.
Here is a simple possible solution
1 2 3 4 5 6 7 8 9 10 11 |
$(document).scroll(function() { if ($(document).scrollTop() >= 50) { // user scrolled 50 pixels or more; // do stuff $("#idName").attr("src","img/imageName.png"); $("#idName").addClass("className"); $(".className").fadeOut(); } else { $("#idName").removeClass("className"); } }); |
Line #1 is targeting the user scroll event when a scroll event is triggered then a jquery function will be called and will check for the scrollTop() function value.
Line #2, If that is more than 50 then the code within the if block will be executed.
You can change the values and Jquery function according to your needs.
You might want to read [Comparison between com and net domain extension]
Final Words on Jquery if Windows Scroll
That is the simple solution to Jquery if windows scroll to certain amount. If you don’t understand anything just let me know in the comment section.