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');
}
}
});
and on css,
.sticky{position:fixed;top:0;}
Cheers!!
Comments
Post a Comment