https://github.com/component/event
Event binding component
https://github.com/component/event
Last synced: 3 months ago
JSON representation
Event binding component
- Host: GitHub
- URL: https://github.com/component/event
- Owner: component
- License: mit
- Created: 2012-09-05T22:54:43.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2022-12-29T17:00:28.000Z (almost 3 years ago)
- Last Synced: 2025-08-09T03:33:09.695Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 37
- Watchers: 5
- Forks: 12
- Open Issues: 2
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
README
# event
Element event binding component.
## Installation
$ component install component/event
## Example
```js
var events = require('event');
var a = document.querySelector('a');
function onclick(e) {
e.preventDefault();
console.log(e.target);
events.unbind(a, 'click', onclick);
}
events.bind(a, 'click', onclick);
```
## API
### .bind(el, type, callback, [capture])
Bind to `el`'s event `type` with `callback`,
returns the `callback` passed.
### .unbind(el, type, callback, [capture])
Unbind `el`'s event `type` `callback`,
returns the `callback` passed.
## License
MIT