javascript - Sticky Element catching on down scroll and catching on up scroll -
i have sticky side bar , right using js have catching , staying fixed t point. when scroll need catch , not go further starting point. code far. $(window).scroll(function(e){ $el = $('.why_social'); if ($(this).scrolltop() > 735 && $el.css('position') != 'fixed'){ $('.why_social').css({'position': 'fixed', 'top': '-62px'}); } }); you should have add opposite check. should started. $(window).scroll(function(e){ $el = $('.why_social'); if ($(this).scrolltop() > 735 && $el.css('position') !== 'fixed') { $('.why_social').css({'position': 'fixed', 'top': '-62px'}); } if ($(this).scrolltop() <= 735 && $el.css('position') === 'fixed') { { $('.why_social').css({'position': ''}); // remove `position: fixed;` } }); btw: if you...