gaspard-collection 0.1.1
Manipulate collection of DOM elements
Use GaspardCollection class to perform actions on Elements
Name | Type | Description | |
---|---|---|---|
elements= | Array.<Element> Element string |
DOM Elements, Element, or string to query the DOM | Optional |
import GaspardCollection from 'gaspard-collection'
const collection = new GaspardCollection('div.highlight')
collection
.css('background-color', 'green')
.find('p:first-child') // returns a new gaspard collection
.addClass('introduction')
.fadeIn(400)
.elements // Array of matched elements
.forEach(element => {
console.log('div.highlight first paragraph', element)
})
GaspardCollection
GaspardCollection containing elements
Apply a method on each elements and returns the collection to chain methods
Name | Type | Description | |
---|---|---|---|
method | Function |
Accept a method to run on each elements | |
params | any |
A list of argument to call the method with |
GaspardCollection
GaspardCollection containing elements
Add classes to each elements
Name | Type | Description | |
---|---|---|---|
classNames | string |
GaspardCollection
GaspardCollection containing elements
Toggle classes to each elements
Name | Type | Description | |
---|---|---|---|
classNames | string |
||
state | boolean |
GaspardCollection
GaspardCollection containing elements
Remove classes to each elements
Name | Type | Description | |
---|---|---|---|
classNames | string |
GaspardCollection
GaspardCollection containing elements
Set attribute to each elements
Name | Type | Description | |
---|---|---|---|
attribute | string |
||
value | any |
GaspardCollection
GaspardCollection containing elements
Set CSS value to each elements
Name | Type | Description | |
---|---|---|---|
ruleName | string |
||
value | string |
GaspardCollection
GaspardCollection containing elements
Insert content before each elements
Name | Type | Description | |
---|---|---|---|
htmlString | string |
GaspardCollection
GaspardCollection containing elements
Insert content after each elements
Name | Type | Description | |
---|---|---|---|
htmlString | string |
GaspardCollection
GaspardCollection containing elements
Prepend element to each elements
Name | Type | Description | |
---|---|---|---|
element | Element |
GaspardCollection
GaspardCollection containing elements
Append element to each elements
Name | Type | Description | |
---|---|---|---|
element | Element |
GaspardCollection
GaspardCollection containing elements
Remove each elements
GaspardCollection
GaspardCollection containing elements
Set text to each elements
Name | Type | Description | |
---|---|---|---|
textString | string |
GaspardCollection
GaspardCollection containing elements
Set html to each elements
Name | Type | Description | |
---|---|---|---|
htmlString | string |
GaspardCollection
GaspardCollection containing elements
Replace each elements
Name | Type | Description | |
---|---|---|---|
htmlString | string |
GaspardCollection
GaspardCollection containing elements
Fade in each elements
Name | Type | Description | |
---|---|---|---|
duration | number |
GaspardCollection
GaspardCollection containing elements
Fade out each elements
Name | Type | Description | |
---|---|---|---|
duration | number |
GaspardCollection
GaspardCollection containing elements
Hide each elements
GaspardCollection
GaspardCollection containing elements
Show each elements
GaspardCollection
GaspardCollection containing elements
Attach an event handler function for each elements
Name | Type | Description | |
---|---|---|---|
eventName | string |
||
eventHandler | Function |
GaspardCollection
GaspardCollection containing elements
Remove an event handler function for each elements
Name | Type | Description | |
---|---|---|---|
eventName | string |
||
eventHandler | Function |
GaspardCollection
GaspardCollection containing elements
Execute all handlers to each elements
Name | Type | Description | |
---|---|---|---|
eventName | string |
||
data | Object |
GaspardCollection
GaspardCollection containing elements
Returns a collection of matched elements either found in the DOM based on passed argument
Name | Type | Description | |
---|---|---|---|
selectorOrElement | string Element |
Accepts a string containing a CSS selector which is then used to match a set of elements, or an Element |
GaspardCollection
GaspardCollection containing elements
Documentation generated with doxdox.