Update on.md
This commit is contained in:
@ -2,13 +2,9 @@
|
|||||||
|
|
||||||
Adds an event listener to an element with the ability to use event delegation.
|
Adds an event listener to an element with the ability to use event delegation.
|
||||||
|
|
||||||
Use `EventTarget.addEventListener()` to add an event listener to an element. If there is a
|
Use `EventTarget.addEventListener()` to add an event listener to an element. If there is a `target` property supplied to the options object, ensure the event target matches the target specified and then invoke the callback by supplying the correct `this` context.
|
||||||
`target` property supplied to the options object, ensure the event target matches the
|
Returns a reference to the custom delegator function, in order to be possible to use with [`off`](#off).
|
||||||
target specified and then invoke the callback by supplying the correct `this` context.
|
Omit `opts` to default to non-delegation behavior and event bubbling.
|
||||||
Use `options` to pass options to `addEventListener` or omit it to use bubbling by default.
|
|
||||||
In order to use this function with `off`, the reference to the custom delegator function
|
|
||||||
is returned if the `target` option is specified. Omit `opts` to default to non-delegation
|
|
||||||
behavior and event bubbling.
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const on = (el, evt, fn, opts = {}) => {
|
const on = (el, evt, fn, opts = {}) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user