Coffeekraken.io 0.0.1

closest

Go up the dom three 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 , Function } A css selector to search for or a check function that will be used required

Return { HTMLElement } The element found or null

Example

    import closest from 'sugarcss/js/dom/closest'
const closestElm = closest(myCoolElement, '.my-cool-class');
if (closestElm) {
        // we have found en element that matches the selector
}

Author : Olivier Bossel olivier.bossel@gmail.com