Skip to content

Instantly share code, notes, and snippets.

@markmarkoh
Created May 6, 2011 04:57
Show Gist options
  • Select an option

  • Save markmarkoh/958465 to your computer and use it in GitHub Desktop.

Select an option

Save markmarkoh/958465 to your computer and use it in GitHub Desktop.
$(function() {
var tocWrapper = $("#toc .wrapper");
$("#mainContainer h1").each(function(i,item) {
$("<a />")
.text( $(item).text() )
.attr("href","#")
.data("scrollTo",item)
.appendTo(tocWrapper)
});
});
$("#toc a").live("click", function(e) {
$.scrollTo( $(this).data("scrollTo"), {
duration: 300,
easing: "swing"
});
e.preventDefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment