flxels
v0.2.2
Published
dom element helpers
Readme
flxels
Create HTML elements in JavaScript. TypeScript type definitions included.
API
Create element specified by tag.
function el (tag: string): HTMLElementCreate styled element specified by tag and styles object.
type StylesObject = { [key: string]: string | StylesObject }function styled (tag: string, styles: StylesObject): HTMLElementCreate styled or unstyled h1 element.
Styles object is optional.
function h1 (styles?: StylesObject): HTMLDivElementdiv span h1 h2 p input button
Add class to specified element.
function add_class (element: HTMLElement, className: string): voidRemove class from specified element.
function remove_class (element: HTMLElement, className: string): voidStyle specified element.
Adds a new css class on each call.
function style (element: HTMLElement, styles: StylesObject): voidRestyle specified element.
Assigns new css class.
function restyle (element: HTMLElement, styles: StylesObject): voidAdd text node to specified element.
function add_text (element: HTMLElement, text: string): voidRemove text node from specified element.
If string passed instead of text node, removes string from textContent.
If no text arg passed, removes all text nodes.
function remove_text (element: HTMLElement, textNode?: Text): void