# lodom docs


## factories

Factory function for `lodom` instances. A `lodom` instance is an array-like list of [`Elements`][Element].


### lodom(selector)
expects: `html: String`, returns: `lodom`

Assums strings not starting with `<` as selectors. Passes `selector` to [`Document.querySelectorAll()`][Doc.query] and selects the matching elements.


### lodom(html)
expects: `html: String`, returns: `lodom`

Assums strings starting with `<` to be HTML. Creates and selects the HTML elements using [`Element.innerHTML`][innerHTML].


### lodom(el), lodom([el, ...])
expects: `el: Element | Document | Window`, returns: `lodom`

Selects the given elements.


### lodom(fn)
expects: `fn: Function`, returns: `undefined`

Runs given function as soon as DOM is ready.


### lodom(inst)
expects: `inst: lodom`, returns: `lodom`

Returns `inst`.




## methods


### .each(fn)
expects: `fn: Function`, returns: `lodom`

Invokes given function on each selected element with `fn(el, idx, lodom)` and no context.


### .map(fn)
expects: `fn: Function`, returns: `Array`

Invokes given function on each selected element with `fn(el, idx, lodom)` and no context and returns an array with all results.


### .sel(selector)
expects: `selector: String`, returns: `lodom`

Uses [`Element.querySelectorAll()`][El.query] to select all matching children for all elements.


### .on(type, fn)
expects: `type: String, fn: Function`, returns: `lodom`

Adds an event listener to all elements.


### .off(type, fn)
expects: `type: String, fn: Function`, returns: `lodom`

Removes an event listener from all elements.


### .attr(key)
expects: `key: String, returns: `String`

Gets attribute of first selected element.


### .attr(key, value)
expects: `key: String, value: String`, returns: `lodom`

Sets attribute on all elements.


### .rmAttr(key)
expects: `key: String`, returns: `lodom`

Removes an attribute from all elements.


### .val()
returns: `String`

Gets `.value` property of first selected element.


### .val(value)
expects: `value: misc`, returns: `lodom`

Sets `.value` property on all elements.


### .html()
returns: `String`

Gets joined inner HTML of all elements.


### .html(value)
expects: `value: String`, returns: `lodom`

Sets inner HTML on all elements.


### .text()
returns: `String`

Gets joined text content of all elements.


### .text(value)
expects: `value: String`, returns: `lodom`

Sets text content on all elements.


### .clr()
returns: `lodom`

Remove inner HTML on all elements.


### .rm()
returns: `lodom`

Remove all elements from DOM.


### .app(arg)
expects: `arg: misc`, returns: `lodom`

Append the result of `lodom(arg)` to all elements.


### .appTo(arg)
expects: `arg: misc`, returns: `lodom`

Append all elements to the result of `lodom(arg)`.


### .pre(arg)
expects: `arg: misc`, returns: `lodom`

Prepend the result of `lodom(arg)` to all elements.


### .preTo(arg)
expects: `arg: misc`, returns: `lodom`

Prepend all elements to the result of `lodom(arg)`.


### .cls()
returns: `Array`

Gets class names as list of Strings of first selected element.


### .cls(names)
expects: `names: String`, returns: `lodom`

Sets class names on all elements. Expects space-separated class names.


### .hasCls(name)
expects: `name: String`, returns: `Boolean`

Checks if all elements have given class.


### .addCls(name)
expects: `name: String`, returns: `lodom`

Adds class name to all elements.


### .rmCls(name)
expects: `name: String`, returns: `lodom`

Removes class name from all elements.


[Element]: https://developer.mozilla.org/en-US/docs/Web/API/Element
[innerHTML]: https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML
[Doc.query]: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll
[El.query]: https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll
