findup-element
Version:
Given a child element, climb up the DOM and find the first parent element matching your criteria
30 lines (19 loc) • 889 B
Markdown
Given a child element, climb up the DOM and find the first parent element
matching your criteria.
Useful when dealing with event handlers.
[](https://nodei.co/npm/findup-element/)
Returns the first element passing the `filter(element)` function. Alternatively,
you can pass in an element name as a string or a single `HTMLElement`.
``` javascript
var findup = require('findup-element')
var parent = findup(el, 'div')
var parent = findup(el, canvas)
var parent = findup(el, function(parent) {
return parent.hasAttribute('data-tag')
})
```
MIT. See [LICENSE.md](http://github.com/hughsk/findup-element/blob/master/LICENSE.md) for details.