JavaScript's missing querySibling function.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
index-es5.js
index.js
package.json

README.md

querysibling

JavaScript's missing querySibling function.

Demo: https://jsfiddle.net/ryanpcmcquen/rhg3crvp/

Given element .zot, which occurs after .foo, you could do:

querySibling.previous('.zot', '.foo');

// => Returns `.foo` node.

If you were at .foo and wanted .zot (a next sibling), you could do:

querySibling.next('.foo', '.zot');

// => Returns `.zot` node.

It is available via npm for new-school kids (es6):

https://www.npmjs.com/package/querysibling

Or RawGit for old-school kids (es5):

https://cdn.rawgit.com/ryanpcmcquen/querysibling/923c4e5f10610b505f22b7af7ba1a54d94df8f0f/index-es5.js