coy

coy

element manipulation

Showing:

Popularity

Downloads/wk

36

Maintenance

No Maintenance Data Available

Package

Dependencies

0

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

coy

element attribute manipulation.

npm install coy

###usage

pass node reference to constructor. exposes four methods.

var body = coy(document.body);
body.add
body.remove
body.toggle
body.has

all methods accept an arbitrary number of arguments.

every method but has is chainable.

arguments can be of type string, array, or object.

  • string will add or remove a class to the element.

  • array will add or remove each item as a class to the element.

  • dictionary will add or remove attributes. key as attribute name, value as attribute value.

has returns true only if all attributes match.

e.g.,

coy(document.body).add('class', ['class1', 'class2'], {'id':'element'});

###further examples

var element = coy(document.querySelector(query))
    .add('class')
    .add('class', ['class1', 'class2'])
    .add('class', {'id':'element'})
    .add(['class1', 'class2'])
    .add(['class1', 'class2'], {'id':'element'})
    .add({'id':'element'}, ['class1', 'class2'])
    .add({'id':'element'});

element.remove('class')
    .remove('class', ['class1', 'class2'])
    .remove('class', {'id':'element'})
    .remove(['class1', 'class2'])
    .remove(['class1', 'class2'], {'id':'element'})
    .remove({'id':'element'}, ['class1', 'class2'])
    .remove({'id':'element'});

element.toggle('class')
    .toggle('class', ['class1', 'class2'])
    .toggle('class', {'id':'element'})
    .toggle(['class1', 'class2'])
    .toggle(['class1', 'class2'], {'id':'element'})
    .toggle({'id':'element'}, ['class1', 'class2'])
    .toggle({'id':'element'});

element.has('class')
element.has('class', ['class1', 'class2']);
element.has('class', {'id':'element'});
element.has(['class1', 'class2']);
element.has(['class1', 'class2'], {'id':'element'});
element.has({'id':'element'}, ['class1', 'class2']);
element.has({'id':'element'});

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial