jqTOC: jQuery meets Table of Contents at Nepherim

I think jqTOC is a great plugin. I’m currently using it in my blog to display a TOC for my articles.

Just a small suggestion…

It would be great if it would only display the TOC when it’s needed. I mean, if there are no subheaders then syle:none is aplyed to the toc_container so it doesn’t show up.

I made a small and dirty hack to implement it on my blog but i thing it may be useful to include this functionality in the main script.

The hack only works for my site structure but it should be hard to make it fully portable (there’s only need to replace the .entry-content reference with some independent reference).

// create the main content container if not already created
if (document.getElementById(settings.tocContainer) == null)

// START HACK: Checking if TOC is needed
if ( ($(‘h’+settings.tocStart).parent(“.entry-content”)).length ) {
// END HACK: If it is needed then continue the script

if (settings.tocTopLink) {
$(‘.toc_top’).bind(‘click’, function(){window.scrollTo(0,0);});
// If TOC is not needed then apply display: none to tocContainer
else {
// End of modifications
return this;

I hope it helps