Skip to content

hughsk/findup-element

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

findup-element experimental

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

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.

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 for details.

About

Given a child element, climb up the DOM and find the first parent element matching your criteria

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published