JSPM

nextmatchingelement

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q23252F
  • License MIT

Find the next matching sibling element in the DOM

Package Exports

  • nextmatchingelement

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nextmatchingelement) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

nextMatchingElement

Find the next matching sibling element in the DOM

npm version
NPM

NPM

npm install nextmatchingelement --save

Usage

With Commonjs/Browserify/Webpack

var nextEl = require('nextmatchingelement');

nextEl(el, target, callback);

Parameters

el

el is the starting element, from which the sibling will be found.

target

target is the target element you'd like to select

callback

callback is the callback function you'd like to run once the target element has been found. It takes one argument which is a DOM node of the nextElementSibling found.

Example usage

With HTML like this

    <h3 class="findNext"></h3>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sit dolore commodi, et fuga quas.</p>
    <div class="demo">
        Foo
    </div>

Use JS like this

var findNext = document.querySelector('.findNext');
nextEl(findNext, 'demo', function (target) {
    target.classList.toggle('show-code');
});