Browse the passed element previous siblings to find the first element that matches the passed selector
Name | Type | Description | Status | Default |
---|---|---|---|---|
elm | { HTMLElement } | The element to start on | required | |
selector | { String } | A css selector to search for | required |
Return { HTMLElement } The element found or null
import previous from 'coffeekraken-sugar/js/dom/previous'
const previousElm = previous(myCoolElement, '.my-cool-class');
if (previousElm) {
// we have found en element that matches the selector
}
Author : Olivier Bossel [email protected] https://olivierbossel.com