Guest User

Untitled

a guest
Oct 22nd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. $.fn.followTo = function (pos) {
  2. var $this = this,
  3. $window = $(window);
  4.  
  5. $window.scroll(function (e) {
  6. if ($window.scrollTop() > pos) {
  7.  
  8. $this.css({
  9. position: 'fixed',
  10. top: 0
  11. });
  12.  
  13. } else {
  14. $this.removeAttr('style');
  15. }
  16. });
  17. };
  18. // Calling the function
  19. $('#div').followTo(50);
Add Comment
Please, Sign In to add comment