Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/findup-element
Given a child element, climb up the DOM and find the first parent element matching your criteria
https://github.com/hughsk/findup-element
Last synced: 12 days ago
JSON representation
Given a child element, climb up the DOM and find the first parent element matching your criteria
- Host: GitHub
- URL: https://github.com/hughsk/findup-element
- Owner: hughsk
- License: other
- Created: 2014-05-20T21:12:33.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-05-20T21:12:35.000Z (over 10 years ago)
- Last Synced: 2024-10-17T16:40:30.536Z (22 days ago)
- Language: JavaScript
- Size: 105 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# findup-element [![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)
Given a child element, climb up the DOM and find the first parent element
matching your criteria.Useful when dealing with event handlers.
## Usage
[![NPM](https://nodei.co/npm/findup-element.png)](https://nodei.co/npm/findup-element/)
### el = findup(child, filter)
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')
})
```## License
MIT. See [LICENSE.md](http://github.com/hughsk/findup-element/blob/master/LICENSE.md) for details.