1.0.2 • Published 4 years ago

@feizheng/next-dom-find-ancestor v1.0.2

Weekly downloads
3
License
MIT
Repository
-
Last release
4 years ago

next-dom-find-ancestor

Find the closest ancestor element that has a specific class.

installation

npm install -S @feizheng/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 '@feizheng/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

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago