what i need
- when user scroll down the page i need to add class using js.
problem
its appending class at last of scrolling page.
i need to add class 300px above.
jsfiddle: http://jsfiddle.net/8PkQN/1/
i have tried with : (window.innerHeight + window.scrollY) == $(document).height()
code
var bottom = $(document).height() - $(window).height(); if($(window).scrollTop() + 1 >= bottom - 2200==true) { $(".abslouel_left12").addClass("fixed_left_btm"); }
working code
window.onscroll = function(ev) { if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) { $(".abslouel_left12").addClass("fixed_left_btm"); } }; $(window).scroll(function() { $(this).scrollTop() > 75 && ($(".abslouel_left12").addClass("fixed_left"), $('[data-toggle="tooltip"]').tooltip()), $(this).scrollTop() < 75 && ($(".abslouel_left12").removeClass("fixed_left"), ) if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) { $(".abslouel_left12").removeClass("fixed_left"); }
case 1 when user is at top. no class to be added.
- case 2 when user scroll down add class (.fixed_length).
- case 3 when user scroll to bottom add class(.fixed_length_btm) but the issue is case 3 code is working end of scrolling browser i need it should above footer of page .