Skip to content

Instantly share code, notes, and snippets.

@gigamonkey
Created June 8, 2011 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gigamonkey/1013608 to your computer and use it in GitHub Desktop.
Save gigamonkey/1013608 to your computer and use it in GitHub Desktop.
Now working jQuery/Javascript
// #notes is DIV with overflow: scroll and currentParagraph is an element within that DIV.
// I'm trying to arrange things so that currentParagraph appears at the top of the DIV.
// The trick seems to be to set position: absolute on #notes so it will be the
// offsetParent of its elements and then to scroll like this:
$('#notes').scrollTop($('#notes').scrollTop() + $(currentParagraph).position().top);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment