Examples - xurion/acronymizer.js GitHub Wiki

Table of Contents

Simple

Wrap all occurrences of the word "CSS" in the entire page with the default acronym element.

var body = document.body,
    acron = new Acronymizer({
        element: body,
        pattern: 'CSS'
    });
acron.go();

More options for Acronymizer

Change the default wrapper to an anchor element and set the href attribute.

var body = document.body,
    acron = new Acronymizer({
        element: body,
        pattern: 'CSS',
        wrapper: 'a',
        attributes: {
            href: 'http://www.w3schools.com/css'
        }
    });

    acron.go();

Setters

You can build Acronymizer with some setter functions available.

var acron = new Acronymizer();
acron.setElement(document.body);
acron.setPattern('CSS');
acron.setWrapper('a');
acron.setAttribute('a', 'http://www.w3schools.com/css');
acron.go();

Events

Various events are available to hook into. Here is the beforeWrap event.

var acron = new Acronymizer();
acron.setElement(document.body);
acron.setPattern('CSS');
acron.setWrapper('a');
acron.setEvent('beforeWrap', function (text, wrapper) {
    wrapper.href = 'http://www.w3schools.com/css';
    wrapper.target = '_blank';
});
acron.go();
For more events, see documentation.
⚠️ **GitHub.com Fallback** ⚠️