Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jstnjns/jquery-nearest
The opposite of $.fn.closest()
https://github.com/jstnjns/jquery-nearest
Last synced: 4 days ago
JSON representation
The opposite of $.fn.closest()
- Host: GitHub
- URL: https://github.com/jstnjns/jquery-nearest
- Owner: jstnjns
- Created: 2012-10-31T02:53:58.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2012-10-31T04:39:03.000Z (about 12 years ago)
- Last Synced: 2023-03-11T21:19:16.926Z (almost 2 years ago)
- Language: JavaScript
- Homepage: http://static.jstnjns.com/jquery/nearest/
- Size: 180 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.markdown
Awesome Lists containing this project
README
# jQuery Nearest
There have been few, but significant moments where `.find()` and `.children()` have just not been enough. Instances where the opposite of `.closest()` were necessary. Finding the 'nearest' recursive child element is an expensive task (heck, traversing the DOM in general makes me shiver), but on a rare occasion you'll find it a necessary task. That's where `$().nearest()` debuts.
## Documentation
There's not much to document other than there is one argument, the "filter".
```js
$('body').nearest('.end-child');
```The filter attribute is simply any CSS selector you might pass as a jQuery....query.