ponysmith.github.io

brevityBasic Usage

This example covers the most basic usage of brevity.js. The process is actually very simple

  1. Type your abbreviations in your HTML document just as you normally would
  2. For each abbreviation you want brevity.js to convert into an abbr tag, simply register the abbreviation and expanded text for it in the abbreviations array
  3. Pass the abbreviations array into the brevity() function and watch the magic happen

To see it in action, check out the code below. For simplicity, abbr tags have been highlighted, like this. Hover over an abbr tag to see the expanded text.

Code

Sample HTML

1
2
<p>HTML and CSS are two core technologies for web development.</p>
<p>Notice that brevity.js is case sensitive, so this html isn't converted to an abbr tag.</p>

Sample Javascript

1
2
3
4
5
6
// sample JS
var abbrs = [
    { abbr: 'HTML', title: 'Hypertext Markup Language' },
    { abbr: 'CSS', title: 'Cascading Style Sheets' },
];
brevity(abbrs);

Result

HTML and CSS are two core technologies for web development.

Notice that brevity.js is case sensitive, so this html isn't converted to an abbr tag.