Super light-weight DOM manipulation lib.
Minimal util-layer for applying transformations to DOM.
It's a pretty thin layer on top of DOM APIs.
It has zero dependencies.
npm install ampersand-dom
When setting something to a falsy value:
false all become
"0" in order to allow setting
0 as the text content of an element.
Here are all the methods and their usage:
var dom = ;// sets text content of elementdomtextel 'set text content';// uses classList if availabledom;dom; // => truedom;// removes old if found, adds newdom;// makes sure attribute (with no content) is added// if exists it will be cleared of contentdom;// returns true if that the element has an attribute with that namedom; // => true// completely removes attributedom;// sets attribute to string value given, clearing any current valuedom;// sets display nonedom;// hide takes a second parameter which changes// the css property used to hide the element// sets visibility hiddendom;// shows element, trying to determine it's default display state// based on tagname and getComputedStyle()dom;// show also takes a second parameter which changes// the css property used to show the element// sets visibility on element based on its previous valuedom;// toggle display of element, between show/hidedom;// toggle also takes the same second parameter as show/hide// which changes the css property used to show or hide// the elementdom;// sets inner HTML, takes string or DOMdom;