Skip to content

jQuery plugin that automatically creates unique anchor links for headlines, paragraphs or other specified elements.

Notifications You must be signed in to change notification settings

rnarian/anchor.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

anchor.js

jQuery plugin that automatically creates unique anchor links for headlines, paragraphs or other specified elements.

See a demo on codepen.

Installation

Include anchor.js after the jQuery library:

<script src="/path/to/anchor.min.js"></script>

Usage

$('h1, h2, .huge-heading').anchor();

anchor.js then applies a unique anchor link to each element.

So <h1>Heading</h1> would become:

<h1 class="anchored" id="heading">Heading <a class="anchor" href="#heading">¶</a></h1>

Options

$('h1, h2, .huge-heading').anchor({
    headingClass: 'heading-class', // default is 'anchored'
    anchorClass:  'anchor-class',  // default is 'anchor'
    symbol:       '→',             // default is '¶'
    maxLength:    30               // default is 100
});

About

jQuery plugin that automatically creates unique anchor links for headlines, paragraphs or other specified elements.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published