Tegarmaji

jquery scrollTo using animate

Mar 21st, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Alt #1 : get top offset of an element
  2. $('html,body').animate({
  3.     scrollTop: $('#element').offset().top
  4. }, 1000);
  5.  
  6. // Alt #2 : exact value scroll, ex: y=500
  7. $('html,body').animate( {scrollTop: 500 }, 1000);
Advertisement
Add Comment
Please, Sign In to add comment