A lightweight and lazer-focused DOM manipulation library for building modern web apps.
With blingJS, this:
const container = documentconst articles = containerconst makeBtn = { const btn = document btnclassName = 'btn' return btn} articles
becomes:
const container =
Usage
npm i --save-dev blingjs
or:
yarn add blingjs
Release History
- 0.0.2
- Updated README with docs
API (WIP)
$
Core module
- $
- module.exports ⏏
- new module.exports(selector, [context])
- instance
- .get(index) ⇒
Element
- .first() ⇒
Element
- .last() ⇒
Element
- .appendTo(element)
- .data(key, [value])
- .addClass(...names)
- .get(index) ⇒
module.exports ⏏
new module.exports(selector, [context])
The blingJS Constructor - new
keyword not necessary!
Param | Type | Default | Description |
---|---|---|---|
selector | HTMLElement | string | The selector(s), element(s), or HTML string to convert to a blingJS collection. |
|
[context] | HTMLElement | string | document | Limit the selector param to this context. |
Example
// Using an HTMLElement // CSS Selectors // With contextconst header = // HTML string
Element
$.get(index) ⇒ Returns the element at the specified index in the collection.
Kind: instance method of $
Returns: Element
- The original HTMLElement
Param | Type | Description |
---|---|---|
index | number | The index of the element |
Element
$.first() ⇒ Returns the first element in the collection.
Kind: instance method of $
Returns: Element
- The original HTMLElement
Element
$.last() ⇒ Returns the last element in the collection.
Kind: instance method of $
Returns: Element
- The original HTMLElement
$.appendTo(element)
Appends the collection to the supplied element.
Kind: instance method of $
Param | Type | Description |
---|---|---|
element | Element | The element to append this collection to. |
$.data(key, [value])
Gets or sets a data object to the collection.
Kind: instance method of $
Param | Type | Description |
---|---|---|
key | string | The object key or name attribute. Don't prepend the |
[value] | * | If supplied, will return the value saved previously with the given key |
$.addClass(...names)
Adds a single or list of CSS class names to the collection
Kind: instance method of $
Param |
---|
...names |
Meta
Jeff Miller – @jamiller619 – hello@jamiller.me
Distributed under the MIT license. See LICENSE
for more information.