Create dom elements using css syntax.
npm install asyncly/h
const h = require('h')
Create a div element with the class foo.
h('.foo')
<div class="foo"></div>
Create an input element with the class foo.
h('input.foo')
<input class="foo">
Create an input with more classes
h('input.foo.bar')
<input class="foo bar">
Same as above but with an id (order is not important).
h('input#quxx.foo.bar')
<input id="quxx" class="foo bar">
Create an element with an attribute
h('span[x=y]')
<span x="y"></span>
Create an element with multiple attributes
h('span.foo[x=y][q=hello]')
<span class="foo" x="y" q="hello"></span>
Add child elements.
h('p', 'Hello, World!')
<p>Hello, World.</p>
Add as many child elements as you want, even more h
.
const s = h('span.red', 'World')
h('p', 'Hello, ', s, '!')
<p>Hello, <span class="red">World</span>!</p>