previousElement

Type:Function
Status:stable
Since:1.0.0
Platform:js
@blackbyte.sugar.js.dom.query

Browse the passed element previous siblings to find the first element that matches the passed selector

Params

  1. $elm*-HTMLElement

    The element to start on

  2. selector*-String

    A css selector to search for

Return

  1. -HTMLElement|undefined

    The element found or undefined

Example

import { previousElement } from '@blackbyte/sugar/dom'
const previousElm = previousElement($elm, '.my-cool-class');
if (previousElm) {
  // we have found en element that matches the selector
}

Todo

  • testsnormal