Don't like ads? PRO users don't see any ads ;-)
Guest

Keep a DIV in view as page scrolls

By: MrMistreater on May 17th, 2012  |  syntax: jQuery  |  size: 0.21 KB  |  hits: 53  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. $().ready(function() {
  2.         var $scrollingDiv = $("#scrollingDiv");
  3.         $(window).scroll(function(){                   
  4.                 $scrollingDiv
  5.                         .stop()
  6.                         .animate({"marginTop": ($(window).scrollTop() + 30) + "px"}, "slow");                  
  7.         });
  8. });