event-deleg
v0.0.1-alpha.1
Published
A javascript event delegation library
Downloads
3
Readme
Event delegation
An event delegate library.
Usage
const handleClick = () => {
...
}
// listener
on(button, 'click', handleClick)
// stop
off(button, 'click', handleClick)
// The last parameter is the same as the third parameter of addEventListener
// See https://developer.mozilla.org/zh-CN/docs/Web/API/EventTarget/addEventListener
on(button, 'click', handleClick, true)
// event delegation
on(div, 'click', 'li', handleClick)
// stop
off(div, 'click', handleClick)
// capture
on(div, 'click', 'li', handleClick, true)