Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/afeiship/next-dom-find-ancestor
Find the closest ancestor element that has a specific class.
https://github.com/afeiship/next-dom-find-ancestor
ancestor dom find next
Last synced: 4 days ago
JSON representation
Find the closest ancestor element that has a specific class.
- Host: GitHub
- URL: https://github.com/afeiship/next-dom-find-ancestor
- Owner: afeiship
- License: mit
- Created: 2019-12-31T12:24:40.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-22T09:45:52.000Z (about 4 years ago)
- Last Synced: 2025-01-16T06:56:50.366Z (26 days ago)
- Topics: ancestor, dom, find, next
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# next-dom-find-ancestor
> Find the closest ancestor element that has a specific class.[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]## installation
```bash
npm install -S @jswork/next-dom-find-ancestor
```## usage
```html
Where am I?
``````js
import '@jswork/next-dom-find-ancestor';const el1 = document.querySelector('#target1');
const el2 = document.querySelector('#target2');nx.domFindAncestor(el1, '.ancestor'); // near
nx.domFindAncestor(el2, '.ancestor'); // far
```## resources
- https://stackoverflow.com/questions/22119673/find-the-closest-ancestor-element-that-has-a-specific-class## license
Code released under [the MIT license](https://github.com/afeiship/next-dom-find-ancestor/blob/master/LICENSE.txt).[version-image]: https://img.shields.io/npm/v/@jswork/next-dom-find-ancestor
[version-url]: https://npmjs.org/package/@jswork/next-dom-find-ancestor[license-image]: https://img.shields.io/npm/l/@jswork/next-dom-find-ancestor
[license-url]: https://github.com/afeiship/next-dom-find-ancestor/blob/master/LICENSE.txt[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-dom-find-ancestor
[size-url]: https://github.com/afeiship/next-dom-find-ancestor/blob/master/dist/next-dom-find-ancestor.min.js[download-image]: https://img.shields.io/npm/dm/@jswork/next-dom-find-ancestor
[download-url]: https://www.npmjs.com/package/@jswork/next-dom-find-ancestor