Skip to content

Instantly share code, notes, and snippets.

@andrearufo
Created March 16, 2014 08:06
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 andrearufo/9579983 to your computer and use it in GitHub Desktop.
Save andrearufo/9579983 to your computer and use it in GitHub Desktop.
How to create an index of titles in a HTML page with jQuery
$(window).ready( function(){
var titid = 0;
$('.documentation h3').each(function(){
titid = titid+1;
$(this).attr('id', 'tit'+titid);
$('#indice').append('<li><a href="#tit' + titid + '">' + $(this).text() + '</a></li>');
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment