| 
				
					 | 
			9 月之前 | |
|---|---|---|
| .. | ||
| demo | 9 月之前 | |
| dist | 9 月之前 | |
| src | 9 月之前 | |
| test | 9 月之前 | |
| .editorconfig | 9 月之前 | |
| .npmignore | 9 月之前 | |
| .travis.yml | 9 月之前 | |
| bower.json | 9 月之前 | |
| karma.conf.js | 9 月之前 | |
| package.json | 9 月之前 | |
| readme.md | 9 月之前 | |
A more versatile way of adding & removing event listeners.
You can get it on npm.
npm install good-listener --save
Or bower, too.
bower install good-listener --save
If you're not into package management, just download a ZIP file.
var listen = require('good-listener');
<script src="dist/good-listener.js"></script>
By passing a string selector (see full demo).
listen('.btn', 'click', function(e) {
    console.log(e);
});
Or by passing a HTML element (see full demo).
var logo = document.getElementById('logo');
listen(logo, 'click', function(e) {
    console.log(e);
});
Or by passing a list of HTML elements (see full demo).
var anchors = document.querySelectorAll('a');
listen(anchors, 'click', function(e) {
    console.log(e);
});
By calling the destroy function that returned from previous operation (see full demo).
var listener = listen('.btn', 'click', function(e) {
    console.log(e);
});
listener.destroy();
![]()  | 
![]()  | 
![]()  | 
![]()  | 
![]()  | 
![]()  | 
|---|---|---|---|---|---|
| Latest ✔ | Latest ✔ | Latest ✔ | 9+ ✔ | Latest ✔ | Latest ✔ | 
MIT License © Zeno Rocha