shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
querySelectorAllUp
Type:Function
Status:stable
Since:1.0.0
Platform:js
@blackbyte.sugar.js.dom.query
Go up the dom three to find all the elements that matches the passed selector
Params
- $from*-HTMLElement
The element to start from
- selector*-String|Function
A css selector to search for or a check function that will be used
Return
- -HTMLElement[]
The elements found or an empty array
Example
import { querySelectorAllUp } from '@blackbyte/sugar/dom'
const closestElm = querySelectorAllUp($elm, '.my-cool-class');
if (closestElm) {
// we have found en element that matches the selector
}
// the selector param can be a function that need to return either true or false like so:
querySelectorAllUp($elm, (elm) => {
return elm.hasAttribute('my-cool-attribute')
})Todo
- testsnormal
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space