Automatically Adding a Table of Contents on Website | Toctoc

Toctoc is a jQuery plugin to automatically adds a table of contents to a webpage. A small jQuery TOC plugin that makes it easy to navigate a long webpage via a customizable table of contents and is SEO friendly.

The plug-in creates a collapsible table of contents box containing the anchor list where the ID and Href are generated from all heading elements within the document.


🐙 Github 💻 VS Code 🧰 jQuery


🟠 HTML 🔵 CSS 🟡 JavaScript

How to make use of it:

1. Load the stylesheet toctoc.css for the default model of the table of contents.

<link rel="stylesheet" href="toctoc.css" />

2. Create an empty container by which the TOC field can be positioned.

<div id="toctoc"></div>

3. Load the jQuery JavaScript library and the jQuery toctoc.js plugin.

<script src="/path/to/cdn/jquery.min.js"></script>
<script src="/path/to/toctoc.js"></script>

4. Initialize the plugin to generate a table of contents.


5. Customize the looks of the table of contents.

  headBackgroundColor: '#1c1c1c',
  headTextColor: '#fff',
  headLinkColor: '#add8e6',
  bodyBackgroundColor: '#f5f5f5',
  bodyLinkColor: '#000',
  borderStyle: 'solid',
  borderColor: '#000',
  borderWidth: '2px'

6. Customize the title of the TOC field.

  headText: 'Table of contents'

7. Customize the present/cover labels.

  headLinkText: ['show', 'hide']

8. Determine whether or not to collapse the TOC field on the web page load.

  minimized: false

9. Determine the container by which the plugin appears for heading parts.

  target: 'article'
headBackgroundColorThis is the background color of the table of contents headerString – CSS color“#1c1c1c”
headTextColorThis is the text color of the table of contents headerString – CSS color“#fff”
headLinkColorThis is the link color of the table of contents headerString – CSS color“#add8e6”
bodyBackgroundColorThis is the background color of the table of contents bodyString – CSS color“#f5f5f5”
bodyLinkColorThis is the links color of the table of contents bodyString – CSS color“#000”
borderStyleThis is the border style of the table of contents containerString – CSS border-style“solid”
borderColorThis is the border color of the table of contents containerString – CSS border-color“#000”
borderWidthThis is the border width of the table of contents containerString – CSS border-width“2px”

See Demo And Download


Official Website(ThibaudArros): Click Here

This superior jQuery/javascript plugin is developed by ThibaudArros. For extra Advanced Usage, please go to the official website.

Related Posts


Interactive Data Table Generator with JS/jQuery and JSON | Tabulator

Tabulator allows you to create interactive tables in seconds from any HTML Table, JavaScript array, AJAX data source, or JSON format data. Just include the library in your…


Simple Alert, Confirm, Prompt Popup Using Vanilla JavaScript Library | attention.js

JavaScript provides various built-in functionality to display popup messages for different purposes. Attention JS is a vanillaJS plugin used to create a custom alert, confirm, or Prompt…


Bootstrap 4 Sidebar Menu Responsive Template | MDB

Bootstrap Side Navbar – Responsive sidebar template based on the Bootstrap 4 framework. An easy-to-use, totally responsive, Google Material Design impressed aspect navigation for modern web app…


Lightweight Bootstrap 4 Toast Notification Plugin | BS4 Advanced Toast

A lightweight Bootstrap 4 Toast Notification plugin integrated with JS/jQuery. bs4-toast.js is a JavaScript library that enhances the native Bootstrap toast component with icons, buttons, callbacks, and…


How to Create Audio Visualizations with JavaScript | Wave.js

Audio Visualizer Library – wave.js is a vanilla javascript audio visualization library that provides 20+ creative audio visualization effects to bring more engagement to your visitor. Contribute…


Bootstrap 5 Treeview Dynamically Collapsible | bs5treeview

Bootstrap 5 Tree View is a very simple plug-in for creating a basic and elegant Treeview using BS5. For use with Bootstrap 5, the attributes have been…

Leave a Reply

Your email address will not be published. Required fields are marked *