event-deleg
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-alpha.1 • Public • Published

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)

Package Sidebar

Install

npm i event-deleg

Weekly Downloads

0

Version

0.0.1-alpha.1

License

MIT

Unpacked Size

19.4 kB

Total Files

15

Last publish

Collaborators

  • chennings