Skip to content
A simple table of contents generator written in vanilla JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
src
.gitattributes
.gitignore
LICENSE
README.md
example.html
example.png
tsconfig.json

README.md

JavaScript Table of Contents Generator

This is the repo for a simple vanilla JavaScript table of contents generator. It parses through a document looking for headers and then builds a table of contents by either using existing IDs or creating them.

Example TOC Output

Directory Layout

Folder Files
dist/ Compiled JavaScript, ready to use
src/ Original TypeScript files

Usage

<head>
  <script src="toc.js" type="text/javascript"></script>
  <script>
      window.addEventListener("load", function (event) {
          makeList({
              'target': '#toc',   // Selector for element to place table of contents
              'parent': 'article' // Selector for element to parse headers from (default: 'body')
          });
      });
  </script>
</head>
You can’t perform that action at this time.