Diogo Oliveira de Melo

Table of Contents with JavaScript

Today I needed to create a table of contents on one page I was writing, then I thought maybe there is a better way to do it. If I write the table of contents manually it will take some time and I will have to check it every time I make an update on the text.

If there was a way to automatically generate the table of contents based on h1, h2, … h6 tags it would be really great.

Browsing around, I found this jQuery plugin http://fuelyourcoding.com/scripts/toc/ which introduces the TOC, Table Of Contents plugin for jQuery.

I found this very clever and a great time saver. I hope it can be as useful for other people as it was for me :)