dom-events
dom event binding and triggering
Last updated 7 years ago by shtylman .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install dom-events 
SYNC missed versions from official npm registry.

dom-events

DOM event binding and triggering

browser support

api

.on(element, name, fn [, useCapture])

Bind fn to be called when name is triggered on element.

var eve = require('dom-events');

var div = document.createElement('div');
eve.on(div, 'click', function(ev) {
    console.log(ev);
});

.off(element, name, fn [, useCapture])

Remove fn from being called when name is triggered on element

var eve = require('dom-events');

var fn = function(ev) {
    console.log(ev);
};

var div = document.createElement('div');
eve.on(div, 'click', fn);

// emit some stuff

eve.off(div, 'click', fn);

.once(element, name, fn [, useCapture])

Calls fn the first time the event happens and unsubcribes immediately.

.emit(element, name [, opts])

Force emit name on element.

var eve = require('dom-events');

var div = document.createElement('div');
eve.on(div, 'click', function(ev) {
    console.log(ev);
});

eve.emit(div, 'click'):

license

MIT

Current Tags

  • 0.1.1                                ...           latest (7 years ago)

3 Versions

  • 0.1.0                                ...           8 years ago
  • 0.1.1                                ...           7 years ago
  • 0.0.0                                ...           8 years ago

Copyright 2014 - 2016 © taobao.org |