Skip to content

Instantly share code, notes, and snippets.

@AeonFr
AeonFr / element.js
Last active August 7, 2018 06:29
Function to create DOM elements filled with attributes and content, in one line of JavaScript. Inspired on React.createElement().
/**
* el(tag, options[, innerHTML])
* Creates an HTMLElement object
* and fills it with various attributes and properties.
* Inspired by React's `React.createElement()` function
*
* @param string tag The element's tagname, such as P, DIV, etc.
* @param object options
* An object that can contain key-value pairs of attributes such as
* "aria-label", "itemtype", "disabled", etc.