append-content

1.0.2 • Public • Published

appendContent.js

A jQuery plugin that appends some content an element and adds a class. If the element already has the class, it does nothing. Could be useful in situations where it's not feasible to edit the markup, or you've added some generated content using a pseudo element and need it to actually be in the DOM for screen readers.

How to use

npm install --save append-content
$('.required').appendContent({
  className: 'required--injected',
  content: '<span class="injected-text">(required)</span>',
});

Options

It accepts an object with options.

Option Description Required?
className Class name to apply once the content is appended Required
content The content to append Required

/append-content/

    Package Sidebar

    Install

    npm i append-content

    Weekly Downloads

    2

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • nadavspi