Constructor
new Dollarsign(scope, selector)
Query the given DOM object (or scope) for elements matching selector.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
scope |
Element
|
Document
|
DOM object to manipulate |
selector |
string
|
Element query |
Classes
Members
(readonly) elements
All elements matching the given `selector`. This is calculated
using `querySelectorAll()` if a string selector is given.
Otherwise, we assume the selector is a wrapped element and return
it as a single-position Array.
- Source:
(readonly) length
Counts results in the query. As this depends on `this.elements`, it
is also read-only and is calculated based on the value of that
computed attribute.
- Source:
Methods
each(callback) → {Dollarsign}
Iterate over every element with the given callback function.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
callback |
elementIterator
|
Function to call on each iteration. |
(generator) iterator()
Allow iteration over this object using `for..of` loops. This is
also used to iterate over objects with `this.each()`, but with
that function we provide a bit more functionality. This will only
iterate over the elements and not change the `this` or wrap each
element in a Dollarsign object.
- Source:
toString()
This allows us to identify Dollarsign objects without needing to
use `instanceof`. In bundled environments, `instanceof` doesn't
work because the class names can change.
- Source:
Type Definitions
elementIterator(element, index)
Function executed when iterating over a collection of DOM elements.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
element |
Dollarsign
|
Each element selected from the DOM. |
index |
Number
|
Index number of each element in the Array. |