Snippet format update
To match the starter (for the migration)
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
### on
|
||||
---
|
||||
title: on
|
||||
tags: browser,event,intermediate
|
||||
---
|
||||
|
||||
Adds an event listener to an element with the ability to use event delegation.
|
||||
|
||||
@ -19,4 +22,4 @@ const fn = () => console.log('!');
|
||||
on(document.body, 'click', fn); // logs '!' upon clicking the body
|
||||
on(document.body, 'click', fn, { target: 'p' }); // logs '!' upon clicking a `p` element child of the body
|
||||
on(document.body, 'click', fn, { options: true }); // use capturing instead of bubbling
|
||||
```
|
||||
```
|
||||
Reference in New Issue
Block a user