0.5.0 • Published 7 years ago

tocjs v0.5.0

Weekly downloads
2
License
GPL-2.0+
Repository
github
Last release
7 years ago

TocJS

A jQuery plug-ins that automatically create a table of contents of the article.

##概要

記事の見出し(h1-6タグ)を元に、自動的に目次を作成します。 対象範囲の選択や連番機能、特定の見出し除外などの機能があります。

インストール

jQueryとtoc.jsを読み込みます。

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="path/to/toc.js"></script>

使い方

目次を作成したい場所に、この空divを書きます。

<div class="toc"></toc>

目次対象とする記事範囲をdivで囲みます。この囲まれた中の見出しタグが、目次に反映されます。

<div class="toc-src">

  <!-- 対象となる記事のHTML -->
  
</div>

同ページ内にスクリプトを書きます。

<script>
$(function(){
  $('.toc-src').toc();
});
</script>

オプション

<script>
$(function(){
  $('.toc-src').toc(){
    exclude: '.toc-exclude'
    heading: 'h2, h3'
    include: null
    menu: '.toc'
    number: true
    title: 'Table of Contents'
    titleElement: 'h2'
  });
});
</script>
0.5.0

7 years ago

0.4.2

7 years ago

0.4.0

7 years ago

0.3.3

8 years ago

0.3.2

8 years ago