Skip to content

Latest commit

 

History

History
63 lines (41 loc) · 1.69 KB

readme.md

File metadata and controls

63 lines (41 loc) · 1.69 KB

delegate

Lightweight event delegation.

Install

You can get it on npm.

npm install delegate --save

Or bower, too.

bower install delegate --save

If you're not into package management, just download a ZIP file.

Setup

Node (Browserify)
var delegate = require('delegate');
Browser (Standalone)
<script src="dist/delegate.js"></script>

Usage

Add event delegation

delegate(document.body, '.btn', 'click', function(e) {
    console.log(e.delegateTarget);
}, false);

Remove event delegation

var delegation = delegate('.btn', 'click', function(e) {
    console.log(e.delegateTarget);
}, false);

delegation.destroy();

Browser Support

Chrome logo Firefox logo Internet Explorer logo Opera logo Safari logo
Latest ✔ Latest ✔ IE 9+ ✔ Latest ✔ Latest ✔

License

MIT License © Zeno Rocha