Class: NodeCollection

NodeCollection

A mutable collection of DOM nodes. It subclasses the native Array class (but take note that the .clone(), .remove(), and .filter() functions have been overridden), and has all of the main DOM-manipulating functions. NodeCollection can also be reference by its shorter alias: NC.

Note: Since it is nearly impossible to fully subclass the Array class in JavaScript, there is one minor hiccup with the way NodeCollection subclasses Array. The instanceof operator will not report that NodeCollection is an instance of anything other than a NodeCollection. It also will not report that NodeCollection is a function. This is demonstrated in the following code:

var nc = new NodeCollection(); // (or 'new NC()' for short)
nc instanceof NodeCollection;  // true
nc instanceof NC;     // true
nc instanceof Array;  // false
nc instanceof Object; // false
nc.constructor instanceof Function; // false
All other operations, such as Array.isArray() and typeof, will work correctly.

It should be noted that all functions that do not have a specified return value, return the calling object, allowing for function chaining.

new NodeCollection()

Same constructor as Array.

Source:

Mixes In

Methods

add(selector) → {NodeCollection}

Adds the queried elements to a copy of the existing collection (if they are not already in the collection) and returns the result.
Parameters:
Name Type Description
selector String

A CSS selector to use to find elements to add to the collection.

Do not assume that this method appends the nodes to the existing collection in the order they are passed to the method (that's what concat is for). When all nodes are members of the same document, the resulting collection will be sorted in document order; that is, in order of each node's appearance in the document. If the collection consists of nodes from different documents or ones not in any document, the sort order is undefined (but nodes in the collection that are in the same document will still be in document order).

Source:
Returns:
Type
NodeCollection

The result of unioning the queried elements with the current collection.

add(html) → {NodeCollection}

Adds the newly created elements to a copy of the existing collection and returns the result.

Parameters:
Name Type Description
html String

An HTML fragment to add to the collection.

Source:
Returns:
Type
NodeCollection

The result adding the elements created with the HTML to current collection.

add(node) → {NodeCollection}

Adds the node to a copy of the existing collection (if it is not already in the collection) and returns the result.
Parameters:
Name Type Description
node Node

A DOM Node.

Do not assume that this method appends the node to the existing collection (that is what push is for). When all nodes are members of the same document, the resulting collection will be sorted in document order; that is, in order of each node's appearance in the document. If the collection consists of nodes from different documents or ones not in any document, the sort order is undefined (but nodes in the collection that are in the same document will still be in document order).

Source:
Returns:
Type
NodeCollection

The result of adding the node to the current collection.

add(nodes) → {NodeCollection}

Returns the union of the current collection of nodes and the input one.
Parameters:
Name Type Description
nodes NodeCollection | NodeList | HTMLCollection | Array.<Node>

Do not assume that this method appends the nodes to the existing collection in the order they are passed to the method (that's what concat is for). When all nodes are members of the same document, the resulting collection will be sorted in document order; that is, in order of each node's appearance in the document. If the collection consists of nodes from different documents or ones not in any document, the sort order is undefined (but nodes in the collection that are in the same document will still be in document order).

Source:
Returns:
Type
NodeCollection

The result of adding the input nodes to the current collection.

addClass(className)

Adds the input class name to all elements in the collection.

Parameters:
Name Type Description
className String

The class to be added to each element in the collection.

Source:

afterPut(content)

Inserts content after each node in the collection.

Parameters:
Name Type Argument Description
content String | Node | NodeCollection <repeatable>

One or more HTML strings, nodes, or collections of nodes to insert.

Source:
Throws:
TypeError | NoModificationAllowedError
The subject collection of nodes must only contain nodes that have a ParentNode.

animate(properties, duration, easing, complete())

Performs a custom animation of a set of CSS properties.
Parameters:
Name Type Argument Default Description
properties Object

An object of CSS properties and values that the animation will move toward.

duration Number <optional>
400

A number of milliseconds that specifies how long the animation will run.

easing String <optional>
"swing"

Indicates which easing function to use for the transition. The string can be any CSS transition timing function or "swing".

complete() function <optional>

A function to call once the animation is complete. Inside the function, this will refer to the element that was animated.

Just like NodeCollection#css, CSS properties must be specified the same way they would be in a style sheet since Firebolt does not append "px" to input numeric values (i.e. 1 != 1px).

Unlike jQuery, an object that specifies different easing types for different properties is not supported. (Should it be supported? Tell me why.) However, relative properties (indicated with += or -=) and the toggle indicator are supported.

For more easing options, use Firebolt's easing extension (or just grab some functions from it and use them as the easing parameter).

Source:
See:

appendTo(target)

Appends each node in this collection to the end of the specified target(s).

Parameters:
Name Type Description
target String | ParentNode | NodeCollection

A specific node, collection of nodes, or a selector to find a set of nodes to which each node will be appended.

Source:
Throws:
HierarchyRequestError
The target(s) must implement the ParentNode interface.

appendWith(content)

Appends content to the end of each element in the collection.

Parameters:
Name Type Argument Description
content String | Node | NodeCollection <repeatable>

One or more HTML strings, nodes, or collections of nodes to insert.

Source:
Throws:
HierarchyRequestError
The nodes in the collection must implement the ParentNode interface.

attr(attribute) → {String}

Gets the value of the specified attribute of the first element in the collection.

Parameters:
Name Type Description
attribute String

The name of the attribute who's value you want to get.

Source:
Returns:
Type
String

The value of the attribute.

attr(attribute, value)

Sets the specified attribute for each element in the collection.

Parameters:
Name Type Description
attribute String

The name of the attribute who's value should be set.

value String

The value to set the specified attribute to.

Source:

attr(attributes)

Sets attributes for each element in the collection.

Parameters:
Name Type Description
attributes Object

An object of attribute-value pairs to set.

Source:

beforePut(content)

Inserts content before each node in the collection.

Parameters:
Name Type Argument Description
content String | Node | NodeCollection <repeatable>

One or more HTML strings, nodes, or collections of nodes to insert.

Source:
Throws:
TypeError | NoModificationAllowedError
The subject collection of nodes must only contain nodes that have a ParentNode.

blur()

Calls HTMLElement#blur() on each element in the collection.

Source:

childElements(selector) → {NodeCollection}

Gets the child elements of each element in the collection, optionally filtered by a selector.

Parameters:
Name Type Argument Description
selector String <optional>

A CSS selector used to filter the returned set of elements.

Source:
Returns:
Type
NodeCollection

The set of children, sorted in document order.

children(selector) → {NodeCollection}

Alias for NodeCollection#childElements().

Parameters:
Name Type Argument Description
selector String <optional>

A CSS selector used to filter the returned set of elements.

Source:
Returns:
Type
NodeCollection

The set of children, sorted in document order.

click()

Calls HTMLElement#click() on each element in the collection.

Source:

clone(withDataAndEvents, deepWithDataAndEvents) → {NodeCollection}

Create a deep copy of the collection of nodes.

ProTip: If you want a shallow copy of the collection, use .toNC() (even though that's mainly a NodeList function, NodeCollections also have it in their prototype) or pass the collection into NodeCollection.from().

Parameters:
Name Type Argument Default Description
withDataAndEvents Boolean <optional>
false

A boolean indicating if each node's data and events should be copied over to its clone.

deepWithDataAndEvents Boolean <optional>
value of withDataAndEvents

If false, data and events for the descendants of the cloned nodes will not be copied over. If cloning with data and events and you know the descendants do not have any data or events that should be copied, using this variable (by setting it to false) will improve performance.

Source:
Returns:
Type
NodeCollection

closest(selector) → {Array.<Node>}

For each node in the collection, gets the first node that matches the selector by testing the node itself and traversing up through its ancestors in the DOM tree.
Parameters:
Name Type Description
selector String | Node | Array.<Node>

A CSS selector, a node, or a collection of nodes used to match the node and its parents against.

Note: Unlike jQuery, there is no version of this function where you can provide a "context" element whose children that match the input CSS selector will be searched for a match. This is because it is very easy to get the matching children of an element yourself using Element#QSA() or Element#find() and you may find that one of these functions suits your needs better than the other.

Source:
Returns:
Type
Array.<Node>
  • A collection of "closest" nodes.

contents() → {NodeCollection}

Gets the child nodes of each element in the collection.

If this collection contains duplicates, the returned collection will contain duplicates.

Source:
Returns:
Type
NodeCollection

The collection of all the child nodes of the elements in the collection.

css(propertyName) → {String}

Gets the value of the specified style property of the first element in the collection.

Parameters:
Name Type Description
propertyName String

The name of the style property who's value you want to retrieve.

Source:
Returns:
Type
String

The value of the specifed style property.

css(propertyNames) → {Object.<String, String>}

Gets an object of property-value pairs for the input array of CSS properties for the first element in the collection.

Parameters:
Name Type Description
propertyNames Array.<String>

An array of one or more CSS property names.

Source:
Returns:
Type
Object.<String, String>

An object of property-value pairs where the values are the computed style values of the input properties.

css(propertyName, value)

Sets the specified style property for each element in the collection.

Note: Unlike jQuery, if the passed in value is a number, it will not be converted to a string with 'px' appended to it prior to setting the CSS value. This helps keep the library small and fast and will force your code to be more obvious as to how it is changing the element's style (which is a good thing).

Parameters:
Name Type Description
propertyName String

The name of the style property to set.

value String | Number

A value to set for the specified property.

Source:

css(properties)

Sets CSS style properties for each element in the collection.

Note: Just like the previous function, if a value in the object is a number, it will not be converted to a string with 'px' appended to it to it prior to setting the CSS value.

Parameters:
Name Type Description
properties Object.<String, String, Number>

An object of CSS property-values.

Source:

data() → {Object}

Gets the first element's stored data object.

Source:
Returns:
Type
Object

The element's stored data object.

data(key) → {*}

Get the value at the named data store for the first element as set by .data(key, value) or by an HTML5 data-* attribute.

Parameters:
Name Type Description
key String

The name of the stored data.

Source:
Returns:
Type
*

The value of the stored data.

data(key, value)

Stores arbitrary data associated with each element in the collection.

Parameters:
Name Type Description
key String

A string naming the data to set.

value *

Any arbitrary data to store.

Source:

data(obj)

Stores arbitrary data associated with each element in the collection

Parameters:
Name Type Description
obj Object

An object of key-value pairs to add to each element's stored data.

Source:

empty()

Removes all child nodes from each element in the list.

Source:

fadeIn(duration, easing, complete())

Displays each element in the collection by fading it to opaque.

Parameters:
Name Type Argument Default Description
duration Number <optional>
400

A number of milliseconds that specifies how long the animation will run.

easing String <optional>
"swing"

Indicates which easing function to use for the transition. The string can be any CSS transition timing function or "swing".

complete() function <optional>

A function to call once the animation is complete. Inside the function, this will refer to the element that was animated.

Source:

fadeOut(duration, easing, complete())

Hides each element in the collection by fading it to transparent.

Parameters:
Name Type Argument Default Description
duration Number <optional>
400

A number of milliseconds that specifies how long the animation will run.

easing String <optional>
"swing"

Indicates which easing function to use for the transition. The string can be any CSS transition timing function or "swing".

complete() function <optional>

A function to call once the animation is complete. Inside the function, this will refer to the element that was animated.

Source:

fadeToggle(duration, easing, complete())

Displays or hides each element in the collection by animating its opacity.

Parameters:
Name Type Argument Default Description
duration Number <optional>
400

A number of milliseconds that specifies how long the animation will run.

easing String <optional>
"swing"

Indicates which easing function to use for the transition. The string can be any CSS transition timing function or "swing".

complete() function <optional>

A function to call once the animation is complete. Inside the function, this will refer to the element that was animated.

Source:

filter(selector) → {NodeCollection}

Creates a new NodeCollection containing only the elements that match the provided selector. (If you want to filter against another set of elements, use the intersect function.)

Parameters:
Name Type Description
selector String

CSS selector string to match the current collection of elements against.

Source:
Returns:
Type
NodeCollection

filter(function(value,index,collection)) → {NodeCollection}

Creates a new NodeCollection with all elements that pass the test implemented by the provided function. (If you want to filter against another set of elements, use the intersect function.)

Parameters:
Name Type Description
function(value,index,collection) function

A function used as a test for each element in the collection.

Source:
See:
Returns:
Type
NodeCollection

find(selector) → {NodeList|NodeCollection}

Gets the descendants of each element in the collection, filtered by a selector, collection of elements, or a single element.

Parameters:
Name Type Description
selector String | Element | Array.<Element>

A CSS selector, a collection of elements, or a single element used to match descendant elements against.

Source:
Throws:
TypeError
This error is thrown when the collection contains elements that do not have a `querySelectorAll()` function.
Returns:
Type
NodeList | NodeCollection

finish()

Immediately completes the currently running animation for each element in the collection.

Source:

focus()

Calls HTMLElement#focus() on each element in the collection.

Source:

hide()

Hides each element in the collection.

Source:
See:

html() → {String}

Gets the inner HTML of the first element in the list.

Source:
Returns:
Type
String

The element's inner HTML.

html(innerHTML)

Sets the inner HTML of each element in the list.

Parameters:
Name Type Description
innerHTML String

An HTML string.

Source:

item(index) → {Node}

Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.

Parameters:
Name Type Description
index Number
Source:
See:
Returns:
Type
Node

namedItem(name) → {Element}

Returns the specific node whose ID or, as a fallback, name matches the string specified by name.

Parameters:
Name Type Description
name String
Source:
Returns:
Type
Element

next(selector) → {NodeCollection}

Get the each node's immediately following sibling element. If a selector is provided, it retrieves the next sibling only if it matches that selector.

Parameters:
Name Type Argument Description
selector String <optional>

A CSS selector to match the next sibling against.

Source:
Returns:
Type
NodeCollection

The collection of sibling elements.

nextAll(selector) → {NodeCollection}

Gets all following siblings of each node in the collection, optionally filtered by a selector.

Parameters:
Name Type Argument Description
selector String <optional>

A CSS selector used to filter the returned set of elements.

Source:
Returns:
Type
NodeCollection

The set of following sibling elements in order beginning with the closest sibling.

nextUntil(selector, filter) → {NodeCollection}

Gets the following siblings of each node in the collection, up to but not including the elements matched by the selector, DOM node, or node in a collection.

Parameters:
Name Type Argument Description
selector String | Element | Array.<Node> <optional>

A CSS selector, an element, or a collection of nodes used to indicate where to stop matching following sibling elements.

filter String <optional>

A CSS selector used to filter the returned set of elements.

Source:
Returns:
Type
NodeCollection
  • The set of following sibling elements in order beginning with the closest sibling.

off(events, selector, handler)

Removes one or more event handlers set by .on() or .one().

Parameters:
Name Type Argument Description
events String

One or more space-separated event types, such as "click" or "click keypress".

selector String <optional>

A selector which should match the one originally passed to .on() when attaching event handlers.

handler function <optional>

A handler function previously attached for the event(s), or the special value false (see NodeCollection#on()).

Source:
See:

off(events, selector)

Removes one or more event handlers set by .on() or .one().

Parameters:
Name Type Argument Description
events Object

An object where the string keys represent one or more space-separated event types and the values represent handler functions previously attached for the event(s).

selector String <optional>

A selector which should match the one originally passed to .on() when attaching event handlers.

Source:
See:

off()

Removes all event handlers set by .on() or .one().

Source:
See:

offset() → {Object}

Gets the current coordinates of the first element in the collection relative to the document.

Source:
See:
Returns:
Type
Object

An object containing the coordinates detailing the element's distance from the top and left of the document.

offset(coordinates)

Sets the each element's coordinates relative to the document.

Parameters:
Name Type Description
coordinates Object

An object containing the properties top and left, which are numbers indicating the new top and left coordinates to set for each element.

Source:

on(events, selector, data, handler(eventObject))

Attaches an event handler function for one or more events to each node in the collection.
Parameters:
Name Type Argument Description
events String

One or more space-separated event types, such as "click" or "click keypress".

selector String <optional>

A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.

data * <optional>

Data to be passed to the handler in eventObject.data when an event is triggered.

handler(eventObject) function

A function to execute when the event is triggered. Inside the function, this will refer to the node the event was triggered on. The value false is also allowed as a shorthand for a function that simply does return false.

Check out jQuery's documentation for details. There are only a couple minor differences:

  1. Firebolt does not offer event namespacing.
  2. The native Event object is passed to the handler (with an added data property, and if propagation is stopped, there will be a propagationStopped property set to true).
Source:
See:

on(events, selector, data)

Attaches an event handler function for one or more events to each node in the collection.
Parameters:
Name Type Argument Description
events Object

An object where the string keys represent one or more space-separated event types and the values represent handler functions to be called for the event(s).

selector String <optional>

A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.

data * <optional>

Data to be passed to the handler in eventObject.data when an event is triggered.

Check out jQuery's documentation for details. There are only a couple minor differences:

  1. Firebolt does not offer event namespacing.
  2. The native Event object is passed to the handler (with an added data property, and if propagation is stopped, there will be a propagationStopped property set to true).
Source:
See:

one(events, selector, data, handler(eventObject))

Attaches a handler to an event for each node in the collection. The handler is executed at most once per node, per event type.
Exactly the same as NodeCollection#on() except the event handler is removed after it executes for the first time.

Parameters:
Name Type Argument Description
events String
selector String <optional>
data * <optional>
handler(eventObject) function
Source:
See:

one(events, selector, data)

Attaches a handler to an event for each node in the collection. The handler is executed at most once per node, per event type.
Exactly the same as NodeCollection#on() except the event handler is removed after it executes for the first time.

Parameters:
Name Type Argument Description
events Object
selector String <optional>
data * <optional>
Source:
See:

parent(selector) → {NodeCollection}

Gets the parent of each node in the collection, optionally filtered by a selector.

Parameters:
Name Type Argument Description
selector String <optional>

A CSS selector used to filter the returned set of elements.

Source:
Returns:
Type
NodeCollection
  • The set of parents. Unlike the .parents() function, this set may include Document and DocumentFragment nodes.

parents(selector) → {NodeCollection}

Gets the ancestors of each node in the collection, optionally filtered by a selector.

Parameters:
Name Type Argument Description
selector String <optional>

A CSS selector used to filter the returned set of elements.

Source:
Returns:
Type
NodeCollection
  • The set of ancestors, sorted in reverse document order.

parentsUntil(selector, filter) → {NodeCollection}

Gets the ancestors of each node in the collection, up to but not including the elements matched by the selector, DOM node, or node in a collection.

Parameters:
Name Type Argument Description
selector String | Element | Array.<Node> <optional>

A CSS selector, an element, or a collection of nodes used to indicate where to stop matching ancestor elements.

filter String <optional>

A CSS selector used to filter the returned set of elements.

Source:
Returns:
Type
NodeCollection
  • The set of ancestors, sorted in reverse document order.

prependTo(target)

Prepends each node in this collection to the beginning of the specified target(s).

Parameters:
Name Type Description
target String | ParentNode | NodeCollection

A specific node, collection of nodes, or a selector to find a set of nodes to which each node will be prepended.

Source:
Throws:
HierarchyRequestError
The target(s) must implement the ParentNode interface.

prependWith(content)

Prepends content to the beginning of each element in the collection.

Parameters:
Name Type Argument Description
content String | Node | NodeCollection <repeatable>

One or more HTML strings, nodes, or collections of nodes to insert.

Source:
Throws:
HierarchyRequestError
The nodes in the collection must implement the ParentNoded interface.

prev(selector) → {NodeCollection}

Get the each node's immediately preceeding sibling element. If a selector is provided, it retrieves the previous sibling only if it matches that selector.

Parameters:
Name Type Argument Description
selector String <optional>

A CSS selector to match the previous sibling against.

Source:
Returns:
Type
NodeCollection

The collection of sibling elements.

prevAll(selector) → {NodeCollection}

Gets all preceeding siblings of each node in the collection, optionally filtered by a selector.

Parameters:
Name Type Argument Description
selector String <optional>

A CSS selector used to filter the returned set of elements.

Source:
Returns:
Type
NodeCollection

The set of preceeding sibling elements in order beginning with the closest sibling.

prevUntil(selector, filter) → {NodeCollection}

Gets the preceeding siblings of each node in the collection, up to but not including the elements matched by the selector, DOM node, or node in a collection.

Parameters:
Name Type Argument Description
selector String | Element | Array.<Node> <optional>

A CSS selector, an element, or a collection of nodes used to indicate where to stop matching preceeding sibling elements.

filter String <optional>

A CSS selector used to filter the returned set of elements.

Source:
Returns:
Type
NodeCollection
  • The set of preceeding sibling elements in order beginning with the closest sibling.

prop(property) → {?}

Gets the value of the specified property of the first element in the list.

Parameters:
Name Type Description
property String

The name of the property who's value you want to get.

Source:
Returns:
Type
?

The value of the property being retrieved.

prop(property, value)

Sets the specified property for each element in the list.

Parameters:
Name Type Description
property String

The name of the property to be set.

value *

The value to set the property to.

Source:

prop(properties)

Sets the specified properties of each element in the list.

Parameters:
Name Type Description
properties Object

An object of property-value pairs to set.

Source:

putAfter(target)

Inserts each node in this collection directly after the specified target(s).

Parameters:
Name Type Description
target String | Node | NodeCollection

A specific node, collection of nodes, or a selector to find a set of nodes after which each node will be inserted.

Source:
Throws:
TypeError
The target node(s) must have a ParentNode.

putBefore(target)

Inserts each node in this collection directly before the specified target(s).

Parameters:
Name Type Description
target String | Node | NodeCollection

A specific node, collection of nodes, or a selector to find a set of nodes before which each node will be inserted.

Source:
Throws:
TypeError
The target node(s) must have a ParentNode.

remove(selector)

Removes nodes in the collection from the DOM tree.

Parameters:
Name Type Argument Description
selector String <optional>

A selector that filters the set of elements to be removed.

Source:

removeAttr(attribute)

Removes the specified attribute from each element in the list.

Parameters:
Name Type Description
attribute String

The name of the attribute to be removed.

Source:

removeClass(className)

Removes the input class name from all elements in the list.

Parameters:
Name Type Description
className String

The class to be removed from each element in the collection.

Source:

removeData(name)

Removes a previously stored piece of Firebolt data from each element.
When called without any arguments, all data is removed.

Parameters:
Name Type Argument Description
name String <optional>

The name of the data to remove.

Source:

removeData(list)

Removes previously stored Firebolt data from each element.
When called without any arguments, all data is removed.

Parameters:
Name Type Argument Description
list Array | String <optional>

An array or space-separated string naming the pieces of data to remove.

Source:

removeProp(property)

Removes the specified property from each element in the list.

Parameters:
Name Type Description
property String

The name of the property to remove.

Source:

replaceAll(target)

Replace the target with the nodes in this collection.

Parameters:
Name Type Description
target String | Node | NodeCollection

A specific node, collection of nodes, or a selector to find a set of nodes to be replaced by the nodes in this collection.

Source:
Throws:
TypeError
The target node(s) must have a ParentNode.

replaceWith(content)

Replace each node in the collection with some other content.

Parameters:
Name Type Argument Description
content String | Node | NodeCollection <repeatable>

A specific node, a collection of nodes, or some HTML to replace each node in the collection.

Source:
Throws:
TypeError | NoModificationAllowedError
The subject collection of nodes must only contain nodes that have a ParentNode.

serialize() → {String}

Encode a set of form elements or form control elements as a string for submission in an HTTP request.
Note that only successful controls will have their values added to the serialized string. All button elements (including file input buttons) are also ignored.

ProTip: The best way to serialize a single form is to select the form element and call .serialize() directly on it (see HTMLElement#serialize).

Source:
See:
Throws:
TypeError
Each element in the collection must be an HTMLElement.
Returns:
Type
String

A URL-encoded string of the elements' serialized values or an empty string if no element could be successfully serialized.

show()

Shows each element in the collection. For specifics, see HTMLElement#show.

Source:
See:

siblings(selector) → {NodeCollection}

Gets the sibling elements of each node in the collection, optionally filtered by a selector.

Parameters:
Name Type Argument Description
selector String <optional>

A CSS selector used to filter the returned set of elements.

Source:
Throws:
TypeError
The target node(s) must have a ParentNode.
Returns:
Type
NodeCollection

The set of siblings, sorted in document order.

slideDown(duration, easing, complete())

Displays each element in the collection with a sliding motion.

Parameters:
Name Type Argument Default Description
duration Number <optional>
400

A number of milliseconds that specifies how long the animation will run.

easing String <optional>
"swing"

Indicates which easing function to use for the transition. The string can be any CSS transition timing function or "swing".

complete() function <optional>

A function to call once the animation is complete. Inside the function, this will refer to the element that was animated.

Source:

slideToggle(duration, easing, complete())

Displays or hides each element in the collection with a sliding motion.

Parameters:
Name Type Argument Default Description
duration Number <optional>
400

A number of milliseconds that specifies how long the animation will run.

easing String <optional>
"swing"

Indicates which easing function to use for the transition. The string can be any CSS transition timing function or "swing".

complete() function <optional>

A function to call once the animation is complete. Inside the function, this will refer to the element that was animated.

Source:

slideUp(duration, easing, complete())

Hides each element in the collection with a sliding motion.

Parameters:
Name Type Argument Default Description
duration Number <optional>
400

A number of milliseconds that specifies how long the animation will run.

easing String <optional>
"swing"

Indicates which easing function to use for the transition. The string can be any CSS transition timing function or "swing".

complete() function <optional>

A function to call once the animation is complete. Inside the function, this will refer to the element that was animated.

Source:

stop(jumpToEnd)

Stops the animation currently running on each element in the collection.
Parameters:
Name Type Argument Default Description
jumpToEnd Boolean <optional>
false

A Boolean indicating whether to complete the current animation immediately.

When .stop() is called on an element, the currently-running animation (if any) is immediately stopped. If, for instance, an element is being hidden with .slideUp() when .stop() is called, the element will now still be displayed, but will be a fraction of its previous height. Callback functions are not called.

If jumptToEnd is true, this is equivalent to calling NodeCollection#finish().

Source:

text() → {String}

Gets the combined text contents of each node in the list.

Source:
Returns:
Type
String

The node's text content.

text(text)

Sets the text content of each node in the list.

Parameters:
Name Type Description
text String | *

The text or content that will be converted to a string to be set as each nodes' text content.

Source:

toArray() → {Array}

Returns all of the nodes in the NodeCollection, as an Array.

Source:
Returns:
Type
Array

toggle(showOrHide)

Shows each element in the collection if it is hidden or hides it if it is currently showing.

Parameters:
Name Type Argument Description
showOrHide Boolean <optional>

Indicates whether to show or hide the elements (true => show, false => hide).

Source:
See:

toggleClass(className, addOrRemove)

Toggles the input class name for all elements in the list.

Parameters:
Name Type Argument Description
className String

The class to be toggled for each element in the collection.

addOrRemove Boolean <optional>

Indicates whether to add or remove the class (true => add, false => remove).

Source:

toNC() → {NodeCollection}

Returns a shallow copy of the NodeCollection.
This is mainly just so it can be inherited by NodeList, but can also be used like Array#clone.

Source:
Returns:
Type
NodeCollection

trigger(eventType, extraParameters)

Triggers a real DOM event on each node in the collection for the given event type.

Parameters:
Name Type Description
eventType String

A string containing a JavaScript event type, such as "click" or "submit".

extraParameters *

Additional parameters that will be passed as the second argument to the triggered event handler(s).

Source:

trigger(event, extraParameters)

Uses the input Event object to trigger the specified event on each node in the collection.

Parameters:
Name Type Description
event Event

An Event object.

extraParameters *

Additional parameters that will be passed as the second argument to the triggered event handler(s).

Source:

triggerHandler(eventType, extraParameters)

Executes all handlers attached to the node for an event type.
Parameters:
Name Type Description
eventType String

A string containing a JavaScript event type, such as "click" or "submit".

extraParameters *

Additional parameters that will be passed as the second argument to the triggered event handler(s).

The .triggerHandler() method behaves similarly to .trigger(), with the following exceptions:

  • The .triggerHandler() method does not cause the default behavior of an event to occur (such as a form submission or button click).
  • While .trigger() will operate on all nodes in the collection, .triggerHandler() only affects the first node.
  • Events triggered with .triggerHandler() do not bubble up the DOM hierarchy; if they are not handled by the target node directly, they do nothing.
  • Instead of returning the node, .triggerHandler() returns whatever value was returned by the last handler it caused to be executed. If no handlers are triggered, it returns undefined.
Source:

unwrap()

Remove the each node's parent from the DOM, leaving the node in its place.

Source:
Throws:
TypeError
Each node must have a ParentNode, which in turn must also have a ParentNode.

val() → {String|Array|null}

Retrieves the current value of the first element in the collection. If the element is a <select> element, null is returned if none of its options are selected, and an array of selected options is returned if the element's multiple attribute is present.

Source:
Returns:
Type
String | Array | null

The first element's value.

val(value)

Sets the value of each element in the collection.

Parameters:
Name Type Description
value String

The value to give to each element.

Source:

val(values)

Checks each element in the collection if its current value is in the input array of values and deselects it otherwise (only <input> elements with type checkbox or radio).
If an element is a <select> element, all of its options with a value matching one in the input array of values will be selected and all others deselected. If the <select> element does not allow multiple selection, only the first matching element is selected.

Parameters:
Name Type Description
values Array.<String>

The array of values used to determine if each element (or its options) should be checked (or selected).

Source:

wrapInner({String|Element|Element[]))

Wrap an HTML structure around the contents of each node in the collection.

Parameters:
Name Type Description
{String|Element|Element[])

wrappingElement - CSS selector—to select wrapping element(s)—, HTML string—to create wrapping element(s)—, element, or collection of elements used to specify the wrapping structure.

Source:
Throws:
HierarchyRequestError
The target node(s) must implement the ParentNode interface.

wrapWith({String|Element|Element[]))

Wrap an HTML structure around each node in the collection.

Parameters:
Name Type Description
{String|Element|Element[])

wrappingElement - CSS selector—to select wrapping element(s)—, HTML string—to create wrapping element(s)—, element, or collection of elements used to specify the wrapping structure.

Source:
Throws:
TypeError
The target node(s) must have a ParentNode.