README
Functions
- addClass(c, e) ⇒
boolean
- ascendUntil(e, c) ⇒
object
|undefined
- descendUntil(e, c) ⇒
object
|undefined
- removeClass(c, e) ⇒
boolean
- toggleClass(c1, e, [c2]) ⇒
boolean
boolean
addClass(c, e) ⇒ Kind: global function
Summary: add a CSS class to an HTML element
Returns: boolean
- - whether the className has been added or not (returns false if className was already present)
Param | Type | Description |
---|---|---|
c | string | className to add |
e | object | HTML element to affect |
object
| undefined
ascendUntil(e, c) ⇒ Kind: global function
Summary: traverses the DOM by traveling up parentNodes until the provided condition returns true
Returns: object
| undefined
- node where condition is true, otherwise undefined
Param | Type | Description |
---|---|---|
e | object | HTML element to start with |
c | function | condition test function which will recursively be called with an HTML element argument |
object
| undefined
descendUntil(e, c) ⇒ Kind: global function
Summary: traverses the DOM by traveling down childNodes, iteratively, until the provided condition returns true
Returns: object
| undefined
- node where condition is true, otherwise undefined
Param | Type | Description |
---|---|---|
e | object | HTML element to start with |
c | function | condition test function which will recursively be called with an HTML element argument |
boolean
removeClass(c, e) ⇒ Kind: global function
Summary: remove a CSS class from an HTMl element
Returns: boolean
- - whether the className has been removed or not (returns false if className wasn't present)
Param | Type | Description |
---|---|---|
c | string | className to add |
e | object | HTML element to affect |
boolean
toggleClass(c1, e, [c2]) ⇒ Kind: global function
Summary: Toggles the provided className based on following conditions:
if className present on element, replace it with second provided className, otherwise remove it.
if className not present on element, add it.
if second className present on element, replace it with first className.
Returns: boolean
- - success of operation
Param | Type | Description |
---|---|---|
c1 | string | first className to toggle (add, remove or replace if c2 provided) |
e | Element | HTML element to affect |
[c2] | string | second className to use in replacement of c1 or to be replaced by c1 |