gaspard 0.0.0-development
Lightweight DOM helpers
Determine whether the element is assigned the given class.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
className | string |
The class name to search for |
boolean
Result
Adds the specified class(es) to element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
classNames | string |
One or more space-separated classes to be added to the class attribute |
Void
Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
classNames | string |
One or more space-separated classes to be removed to the class attribute |
Void
Add or remove one or more classes from element, depending on either the class's presence or the value of the state argument.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
classNames | string |
One or more class names (separated by spaces) to be toggled for each element in the matched set | |
state | boolean |
A Boolean value to determine whether the class should be added or removed |
Void
Set the value of an attribute for the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
attribute | string |
The name of the attribute to set | |
value | string |
A value to set for the attribute. If null, the specified attribute will be removed | Optional |
Void
Set a CSS property for the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
ruleName | string |
A CSS property | |
value | string |
A value to set for the property | Optional |
Void
Parses a string into an array of DOM nodes.
Name | Type | Description | |
---|---|---|---|
htmlString | string |
HTML string to be parsed |
Array.<Element>
DOM nodes
Insert content, specified by the second parameter, before the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
htmlString | string |
HTML string to insert |
Void
Insert content, specified by the second parameter, after the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
htmlString | string |
HTML string to insert |
Void
Insert an element, specified by the second parameter, to the beginning of the parent element.
Name | Type | Description | |
---|---|---|---|
parent | Element |
Parent DOM element | |
element | Element |
DOM element to insert |
Void
Insert an element, specified by the second parameter, to the end of the parent element.
Name | Type | Description | |
---|---|---|---|
parent | Element |
Parent DOM element | |
element | Element |
DOM element to insert |
Void
Create a deep copy of the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node |
Element
Cloned DOM Element
Remove the element from the DOM
Name | Type | Description | |
---|---|---|---|
element | Element |
The element to remove |
Void
Set the content of the element to the specified text.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
textString | string |
The text to set as the content of the element. When Number or Boolean is supplied, it will be converted to a String representation. |
Void
Set the HTML contents of the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
htmlString | string |
A string of HTML to set as the content |
Void
Replace element with the provided new content.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
htmlString | string |
The HTML string content to insert |
Void
Fade in or out the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
duration=400 | number |
A number determining how long the animation will run | Optional |
isFadeIn | boolean |
Determine fadeIn or fadeOut |
Void
Display the elements by fading them to opaque.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
duration=400 | number |
A number determining how long the animation will run | Optional |
Void
Hide the element by fading them to transparent.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
duration=400 | number |
A number determining how long the animation will run | Optional |
Void
Hide the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node |
Void
Show the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node |
Void
Remove an event handler.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
eventName | string |
An event type | |
eventHandler | Function |
A handler function previously attached for the event |
Void
Attach an event handler function for the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
eventName | string |
An event type | |
eventHandler | Function |
A function to execute when the event is triggered |
Void
Execute all handlers and behaviors attached to the element for the given event type.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
eventName | string |
An event type | |
data={} | Object |
Additional parameters to pass along to the event handler. | Optional |
Void
Specify a function to execute when the DOM is fully loaded.
Name | Type | Description | |
---|---|---|---|
callback | Function |
A function to execute after the DOM is ready. |
Void
Get the size of the element and its position relative to the viewport.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node |
Object
Object with properties: left, top, right, bottom, x, y, width, height
Get the current coordinates of the element, relative to the document.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node |
Object
Contain the properties top and left
Get the current coordinates of the element, relative to the offset parent.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node |
Object
Contain the properties top and left
Get the current computed outer height (including padding, border, and optionally margin) for the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
withMargin | boolean |
A Boolean indicating whether to include the element's margin in the calculation. |
number
Height of the element, including top and bottom padding, border, and optionally margin, in pixels
Get the current computed outer width (including padding, border, and optionally margin) for the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
withMargin | boolean |
A Boolean indicating whether to include the element's margin in the calculation. |
number
Width of the element, including left and right padding, border, and optionally margin, in pixels
Returns a collection of matched elements either found in the DOM based on passed argument
Name | Type | Description | |
---|---|---|---|
selector | string |
Accepts a string containing a CSS selector which is then used to match a set of elements | |
context=document | Document Element |
A DOM Element or Document | Optional |
Array
A collection of DOM Elements
Check the element against a selector or element, and returns true if the element match the given argument.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
selectorOrElement | string Element |
A string containing a selector expression or a DOM node |
boolean
Is element match with selectorOrElement
Check to see if a DOM element is a descendant of another DOM element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node | |
child | Element |
A potential child DOM node |
boolean
Is element has child as a descendant
Get the immediately preceding sibling of the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node |
Element
The previous DOM node
Get the immediately following sibling of the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node |
Element
The following DOM node
Get the siblings of the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node |
Array
Siblings DOM nodes
Get the parent of the element.
Name | Type | Description | |
---|---|---|---|
element | Element |
A DOM node |
Element
The parent DOM node
Transform kebab case string into camel case strings array
Name | Type | Description | |
---|---|---|---|
kebabCaseString | string |
The kebab case string |
string
The camel case transformed string
Filter incorrect class names.
Name | Type | Description | |
---|---|---|---|
classNames='' | string |
One or more space-separated classes to be filtered | Optional |
Array
Valid class names array
Documentation generated with doxdox.