@thrillworksinc/dom

1.0.2 • Public • Published

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

Name Description Arguments
getElement Gets an individual element selector, context
getElements Gets an array of elements selector, context
createElement Creates an element tagName, attrs, innerHTML
getChildren Get all child nodes of an element element
empty Empties an element of child nodes element
fill Fills an element with child nodes element, ...children
append Appends one element to another parent, child
prepend Prepends one element to another parent, child

Readme

Keywords

none

Package Sidebar

Install

npm i @thrillworksinc/dom

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

3.32 kB

Total Files

4

Last publish

Collaborators

  • marcpelland
  • thrillworksteam
  • driches
  • timziegel
  • jd-tw
  • cjbridge