Skip to content

Files

Latest commit

9124f65 · Jun 12, 2017

History

History
30 lines (23 loc) · 555 Bytes

readme.md

File metadata and controls

30 lines (23 loc) · 555 Bytes

Find closest hyperlink in DOM element

Install

$ npm install --save closest-link

Usage

<article>
  <a href="https://ashiknesin.com">Here is link
    <span id="outer-span">Here is outer-span
      <span id="inner-span">Here is inner-span</span>
    </span>
  </a>
</article>
const closestLink = require('closest-link');
const targetElement = document.querySelector('#inner-span')
closestLink(targetElement);
//=> '<a href="https://ashiknesin.com">...</a>'

License

MIT © Ashik Nesin