Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

add-event-listener

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

add-event-listener

add event listeners in IE and ... everywhere else

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.1K
decreased by-5.1%
Maintainers
1
Weekly downloads
 
Created
Source

add-event-listener

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

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<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

Keywords

FAQs

Package last updated on 19 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc