Skip to main content

Posts

Showing posts with the label jquery

Prevent a html element to stop moving at certain point when page is scrolled

We should make the position of the element fixed. For this, the following small jquery snippet will fulfill the requirement. jQuery(window).scroll(function() {                var button = jQuery("#div").position().top;            var window_top = jQuery(window).scrollTop();                if(window_top <= top || window_top >= button) {             jQuery("#sbasket").removeClass('sticky');                   } else {             if(window_top > top) {                 jQuery("#sbasket").addClass('sticky');             }      ...