Basic Table Of Contents Plugin With Smooth Scroll - tableOfContents
File Size: | 4.21 KB |
---|---|
Views Total: | 578 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
Just another jQuery table of content plugin which detects heading elements within your document, generates anchor links with IDs and allows to scroll smoothly between corresponding anchors.
How to use it:
1. Link the JavaScript file jquery.tableOfContents.js
to your document, after the jQuery library inclusion.
<script src="//code.jquery.com/jquery.min.js"></script> <script src="jquery.tableOfContents.js"></script>
2. Calling the function on document ready will automatically generate an html unordered list based table of contents after the h1
tag.
$('body').tableOfContents();
3. Add a custom CSS class to the table of contents.
$('body').tableOfContents({ ulClass: 'table-of-contents' // default: null });
4. Append the table of contents to a specific element.
$('body').tableOfContents({ appendAfterSelector: '#element' });
This awesome jQuery plugin is developed by gmedaglia. For more Advanced Usages, please check the demo page or visit the official website.