DIV position fixed at top on scroll
You are looking for Div sticky while you scroll the page . Use this below script .
1 2 3 4 5 6 7 8 9 10 11 12 |
<script> $(window).scroll(function(){ if ($(this).scrollTop() > 150) { $('#div_id').addClass('fixed_class'); /* change #div_id to your div id*/ } else { $('#div_id').removeClass('fixed_class'); /* change #div_id to your div id*/ } }); </script> <style> .fixed_class { position:fixed; top:0; left:0;} </style> |