Created
July 21, 2012 21:28
-
-
Save gyrus/3157247 to your computer and use it in GitHub Desktop.
Scroll to an ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Scroll to an ID | |
* | |
* Example: | |
* <code>$( '#content' ).scrollView();</code> | |
* | |
* @link http://stackoverflow.com/questions/1586341/how-can-i-scroll-to-a-specific-location-on-the-page-using-jquery | |
*/ | |
jQuery.fn.scrollView = function () { | |
return this.each( function () { | |
jQuery( 'html, body' ).animate({ | |
scrollTop: jQuery( this ).offset().top | |
}, 1000); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment