|
1 рік тому | |
---|---|---|
.. | ||
CHANGELOG.md | 1 рік тому | |
LICENSE.md | 1 рік тому | |
README.md | 1 рік тому | |
index.js | 1 рік тому | |
package.json | 1 рік тому |
For a given DOM element, find the first ancestor that matches a given CSS selector.
npm install dom-closest
element
(Element): a starting DOM Element.selector
(String): the CSS selector of the ancestor to find.context
(Element): a DOM node to use as search context (optional).
var closest = require('dom-closest');
var photo = document.querySelector('.photo');
var timeline = document.querySelector('.timeline');
closest(photo, '.tweet');
// => Element
closest(photo, '.tweet', timeline);
// => Element