Create DOM nodes from h()
An h2spec h()
function made for creating DOM nodes:
var node = h('div', { class: 'foo bar' }, [
h('span', 'hello world'),
' foobar'
])
document.body.appendChild(node)
npm i h2dom
A h()
function specified in h2spec
-
tag
is an element name passed todoucment.createElement(name)
-
data
is attributes to set on the element -
children
is primitive values (strings, numbers, etc.) or the DOM node
var node = h('p', { class: 'test' }, 'hello world')
// <p class='test'>hello world</p>
document.body.appendChild(node)