Skip to content

Instantly share code, notes, and snippets.

@standout
Created August 31, 2010 19:02
Show Gist options
  • Save standout/559533 to your computer and use it in GitHub Desktop.
Save standout/559533 to your computer and use it in GitHub Desktop.
// Från http://jardenberg.se/b/morgonkommentarerna-nu-lite-nyttigare/
jQuery(document).ready(function() {
// Hämta ankare från URL
var thishash = document.location.hash.substring(1);
if (thishash.length && !isNaN(thishash)) {
// Ankare har kommit in och det är numeriskt
// Traversera alla "li" inom "ol" inom "#content"
var thisli = jQuery('#content ol li').each(function(index) {;
if (index == (thishash - 1)) {
// Sätt klassen "hereweare" på rätt <li>
jQuery(this).addClass('hereweare');
// Hitta fönsterposition på rätt <li>
var pos = jQuery(this).position();
// Scrolla till rätt position
window.scrollTo(pos.left, pos.top);
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment