# add-event-listener

> add event listeners in IE and ... everywhere else

Latest version **1.0.0** (published 2018-11-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install add-event-listener
pnpm add add-event-listener
yarn add add-event-listener
bun add add-event-listener
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-11-19 |
| First published | 2014-01-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Chris Dickinson |
| Maintainers | chrisdickinson |
| Keywords | addEventListener, attachEvent, DOMEvent |

## Links

- npm: https://www.npmjs.com/package/add-event-listener
- Repository: https://github.com/chrisdickinson/add-event-listener
- Homepage: https://github.com/chrisdickinson/add-event-listener#readme
- Issues: https://github.com/chrisdickinson/add-event-listener/issues
- npm.io page: https://npm.io/package/add-event-listener

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-11-19
- 0.0.1 — 2014-01-13

## README

# add-event-listener

Add or remove event listeners in IE8+ / modern browsers.

```javascript
var events = require('add-event-listener')

var el = document.getElementById('#anything')

events.addEventListener(el, 'click', function(ev) {
  events.removeEventListener(el, 'click', arguments.callee)
})

// OR:
var add = require('add-event-listener')

add(el, 'click', function(ev) {

})

```

## API

### require('add-event-listener') -> `{addEventListener, removeEventListener}`
### require('add-event-listener') -> `Function addEventListener`

This package exports `addEventListener` (with a polyfill for `attachEvent`).

`addEventListener` and `removeEventListener` are available as properties on the export.

### addEventListener(element, eventName, listener, useCapture=false|options?) -> undefined

Adds an event listener to an element. On IE&lt;9, uses `attachEvent`. **WARNING**: If `useCapture` is
true and this function is run on IE8, an exception will be thrown (since event capturing
cannot be emulated.)

### removeEventListener(element, eventName, listener, useCapture=false|options?) -> undefined

Remove an event listener from an element.

## Meta

[MIT Licensed](LICENSE.mit)

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