1.0.2 • Published 5 years ago

@thrillworksinc/dom v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

dom

A collection of useful DOM interaction functions.

Usage

import { getElement, getElements, createElement, append } from '@thrillworksinc/dom';

// Query and loop through elements
getElements('.hide-me').forEach(element => {
  element.style.display = 'none';
});

// Create and append elements
const parent = getElement('.container');
const child = createElement('a', { href: '#', className: 'my-cool-anchor' }, "Click me!");
append(parent, child);

// Query an element with a parent context
getElement('.my-cool-anchor', parent);

Functions

NameDescriptionArguments
getElementGets an individual elementselector, context
getElementsGets an array of elementsselector, context
createElementCreates an elementtagName, attrs, innerHTML
getChildrenGet all child nodes of an elementelement
emptyEmpties an element of child nodeselement
fillFills an element with child nodeselement, ...children
appendAppends one element to anotherparent, child
prependPrepends one element to anotherparent, child
1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago