@jswork/next-dom-find-ancestor

1.0.0 • Public • Published

next-dom-find-ancestor

Find the closest ancestor element that has a specific class.

version license size download

installation

npm install -S @jswork/next-dom-find-ancestor

usage

<div class="far ancestor">
    <div id="target2">
      <div class="near ancestor">
          <p id="target1">Where am I?</p>
      </div>
    </div>
</div>
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

license

Code released under the MIT license.

Readme

Keywords

Package Sidebar

Install

npm i @jswork/next-dom-find-ancestor

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

5.18 kB

Total Files

5

Last publish

Collaborators

  • afeiship