# closest

> Find the closest parent that matches a selector.

Latest version **0.0.1** (published 2013-03-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install closest
pnpm add closest
yarn add closest
bun add closest
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2013-03-13 |
| First published | 2013-03-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Jonathan Ong |
| Maintainers | forbeslindesay |
| Keywords | browserify, CSS, selector, closest, parents, jquery |

## Links

- npm: https://www.npmjs.com/package/closest
- Repository: https://github.com/ForbesLindesay/closest
- npm.io page: https://npm.io/package/closest

## Dependencies (1)

- [matches-selector](https://npm.io/package/matches-selector.md) 0.0.1

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2013-03-13

## README

# Closest

Similar to jQuery's `$.fn.closest` and `$.fn.parents`.
Finds the closest parent that matches a selector.

## Installation

    $ npm install closest

## API

### `closest(element, selector, checkSelf)`

* element - will check this elements parents
* selector - CSS selector to match parents
* checkSelf - check `element`.
  If falsey, will begin with `element.parentNode` and is synonymous to `$.fn.parents`.
  Otherwise, it's `$.fn.closest`.

Example:

```javascript
var closest = require('cosest');

closest(document.body, 'html') === document.documentElement
closest(document.body, 'body', true) === document.body
closest(document.documentElement, 'html') == null
```

## License

  MIT

---
_Source: https://npm.io/package/closest · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
