A plugin that generates table of contents(TOC) dynamically for both jQuery or non-jQuery.

Install

  1. bower install jquery-toc

Compatibility

  1. non-jQuery version works on IE9+
  2. jQuery version works on anywhere with jQuery

Showcase

https://idiotwu.me/understanding-es6-promise/

Usage

non-jQuery

  1. // returns an ordered-list of headers in page content
  2. varlist =initTOC(options);
  3. // then you can append it to anywhere you like
  4. container.appendChild(list);

jQuery

  1. // will append TOC list to target element
  2. $(elem).initTOC(options);

Options

  1. initTOC({
  2. selector:'h1, h2, h3, h4, h5, h6',
  3. scope:'body',
  4. overwrite:false,
  5. prefix:'toc'
  6. })

License

MIT.

Latest Posts

No posts.
No posts.