Class: DOMCollection

DOMCollection

new DOMCollection(selector, contextnullable)

Wrapper that holds a collection of DOM elements and allows for easy group modifications to each of them

Parameters:
Name Type Attributes Description
selector string

A CSS selector to be used to fetch elements

context DOMNode <nullable>

The context in which the CSS selector will be used. If empty then document will be used a context. If some DOMNode element is passed, the collection will load only elements within that context that match the selector

Since:
  • 1.0.0
Source:

Members

elements :Array

A list of the DOMNode elements that fall within the collection

Type:
  • Array
Source:

Methods

addClass(className) → {void}

Adds a CSS class to all elements from the collection

Parameters:
Name Type Description
className string

The CSS class to be applied

Source:
Returns:
Type
void

addEventListener(eventType, callback) → {void}

Adds event listener to all DOMNode elements within the collection

Parameters:
Name Type Description
eventType eventType

The type of the event to listen for

callback function

The function to be executed when the event occurs

Source:
Returns:
Type
void

css(styles) → {void}

Applies CSS styles to all elements from the collection

Parameters:
Name Type Description
styles object

An object representation of the CSS styles to be applied to the elements from the collection

Source:
Returns:
Type
void

each(callback) → {void}

Executes a function for all elements from the collection

Parameters:
Name Type Description
callback function

The function to be executed for each of the elements

Source:
Returns:
Type
void

filter(selector) → {DOMCollection}

Filters elements from the collection, so only ones that meet a provided CSS selector remain

Parameters:
Name Type Description
selector string

CSS selector to test the elements against

Source:
Returns:
Type
DOMCollection

find(selector) → {DOMCollection}

Finds child elements to the ones from the collection that match a specific CSS selector

Parameters:
Name Type Description
selector string

CSS selector to describe desired child elements

Source:
Returns:
Type
DOMCollection

remove() → {void}

Detaches from the DOM all elements from the collection

Source:
Returns:
Type
void

removeClass(className) → {void}

Removes a CSS class from all elements from the collection

Parameters:
Name Type Description
className string

The CSS class to be removed

Source:
Returns:
Type
void

removeEventListener(eventType, callback) → {void}

Remves a previously assigned event listener to all of the elements from the collection. The same reference to the callback function must be provided, otherwise the method will not work.

Parameters:
Name Type Description
eventType string

The type of the event to remove listener for

callback function

The function to be removed as handler

Source:
Returns:
Type
void