_____________________________
___________/\/\/\/\/\/\______
__________/\_________________
_________/\/\/\/\/\__________
________/\/\_________________
_______/\/\/\/\/\/\__________
_____________________________
Tiny DOM manipulation helper with a familiar fluent API.
npm install @superstructure.net/e
Note: This library comes as es6 module only. If you use a transpiler like babel or swc make sure to include
/node_modules/@superstructure.net/e
in your transpiler’s config.
import E from @superstructure.net/e;
// create collection
new E('.my-selector');
new E('[data-module-role="button"]');
new E(elementOrNodeList);
// create element
new E('<div></div>');
// create element and do stuff
new E('<p></p>')
.setAttr('data-module-role', 'title')
.setText('Groovy 🎷')
.addClass('active')
.appendTo('body')
Filter the current collection by a selector or an index.
Get children of the current collection matching selector
.
Gets the closest parent matching selector
.
Append nodes to the current collection.
Append the current collection to the passed nodes.
Prepend nodes to the current collection.
Prepend the current collection to the passed nodes.
Clone the collection.
Remove the collection from DOM.
Add class
to the collection.
Remove class
from the collection.
Toggle class
on the collection.
Set attribute key
to value
. If namespace
is passed the key used is data-{namespace}-{key}
.
Get attribute value of key
. If namespace
is passed the key used is data-{namespace}-{key}
.
Toggle attribute key
between values
. If namespace
is passed the key used is data-{namespace}-{key}
.
values
must be an array containing exactly two strings.
Set text content of the first collection entry;
Get text content of the first collection entry;
Set inner HTML of the first collection entry;
Get inner HTML of the first collection entry;
Apply styles passed as a key-value-based object. Like {fontSize:'2rem',color:'yellow'}
.
Get collection entry at index
. Returns all collection entries if no index is passed.
Returns true
if the collection is empty.
Force repaint on colection entries.
Don’t be silly, no one is using JQuery these days, right? 😇
You absolutely could but isn’t it nice to have a chainable API?