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'); } ...
IT graduate and a professional web developer having specialization on magento, ci, opencart, wordpress