$ npm install delegate-events
Low-level event delegation component. Forked from component/delegate for use with browserify.
$ npm install delegate-events
var delegate = require('delegate-events');
var ul = document.querySelector('ul');
var n = 0;
var fn = delegate.bind(ul, 'li a', 'click', function(e){
console.log(e.target);
console.log(e.delegateTarget); // => "<a>"
if (++n == 3) {
console.log('unbind');
delegate.unbind(ul, 'click', fn, false);
}
}, false);
Bind and return a callback which may be passed to .unbind()
.
Unbind.
npm test
.test/index.html
in a browser.MIT
© 2010 - cnpmjs.org x YWFE | Home | YWFE