Skip to content
add event listeners in IE and ... everywhere else
JavaScript
Branch: master
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.
.gitignore
LICENSE.mit
README.md
index.js
package.json
test.js

README.md

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

You can’t perform that action at this time.