Skip to content

Instantly share code, notes, and snippets.

@clawfire
Created October 27, 2011 15:24
Show Gist options
  • Select an option

  • Save clawfire/1319869 to your computer and use it in GitHub Desktop.

Select an option

Save clawfire/1319869 to your computer and use it in GitHub Desktop.
scrollTo() without plugin
<div id="top">Hello, I'm the top-gun!</div>
<div id="bottom">Hello, I'm the bottom end :(</div>
var documentBody = (($.browser.chrome)||($.browser.safari)) ? document.body : document.documentElement;
$('#top').click(function() {
$(documentBody).animate({scrollTop: $('#bottom').offset().top}, 2000,'easeInOutCubic');
});
$('#bottom').click(function() {
$(documentBody).animate({scrollTop: $('#top').offset().top}, 2000,'easeInOutCubic');
});
#top {
position: absolute;
top: 0;
}
#bottom {
position: absolute;
top: 1200px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment