Created
June 8, 2010 09:35
-
-
Save ctrochalakis/429817 to your computer and use it in GitHub Desktop.
Quick TOC creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var create_toc = function create_toc(){ | |
var toc = '<div id="toc_container"><ul id="toc"><li><strong>Περιεχόμενα</strong></li></ul></div>'; | |
$('h2').after(toc); | |
$('h3').each( function (){ | |
var text = $(this).text(); | |
var anchor = '#' + text.replace(/ /g,'+'); | |
$('#toc').append('<li><a href="'+ anchor + '">' + text + '</a></li>'); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment