Dolphin Wood 46fee9e21f v0.0.2
fix: jump to anchor after reload
2015-05-18 14:28:08 +08:00
2015-05-18 14:28:08 +08:00
2015-05-18 14:28:08 +08:00
2015-05-18 13:02:17 +08:00
2015-05-18 10:51:25 +08:00
2015-05-18 14:28:08 +08:00
2015-05-18 13:02:17 +08:00
2015-05-18 00:05:07 +08:00
2015-05-18 14:28:08 +08:00
2015-05-18 14:28:08 +08:00

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

Install

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

// returns an ordered-list of headers in page content
var list = initTOC(options);

// then you can append it to anywhere you like
container.appendChild(list);

jQuery

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

Options

initTOC({
    selector: 'h1, h2, h3, h4, h5, h6',
    scope: 'body',
    overwrite: false,
    prefix: 'toc'
})
  • String:selector: headers selector, default is 'h1, h2, h3, h4, h5, h6'.
  • String:scope: selector to specify elements search scope, default is 'body'.
  • Boolean:overwrite: whether to overwrite existed headers' id, default is false, which means plugin will preserve the existed id property and create a string like toc-1 for those don't have id assigned.
  • String:prefix: string to prepend to id/href property, default is 'toc', which generates a string like toc-0.

License

MIT.

S
Description
Table of Contents Generator Plugin for (non-)jQuery
Readme MIT
59 KiB
Languages
JavaScript 60.4%
HTML 39.6%