div fixed on scroll, scorll js, js for fixed div when scroll

JS:-

<script>
            jQuery(function($) {
  function fixDiv() {
    var $cache = $('#getFixed');
    if ($(window).scrollTop() > 147)
      $cache.css({
        'position': 'fixed',
        'top': '0px',
        'display': 'block'
      });
    else
      $cache.css({
        'position': 'relative',
        'top': 'auto',
        'display': 'none'       
      });
  }
  $(window).scroll(fixDiv);
  fixDiv();
});
        </script>



HTML:-

<div class="col-md-12" id="getFixed" style="display:none; z-index: 99; background-color: rgb(255, 255, 255); left: 0px; right: 0px; width: 100%;">

</div>

Comments

Popular posts from this blog