Created
January 7, 2020 02:24
-
-
Save colabottles/ccb61b350f879d4c994bfb56592d39f0 to your computer and use it in GitHub Desktop.
Listening for events and user interactions // source https://jsbin.com/wabamo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>Listening for events and user interactions</title> | |
| </head> | |
| <body> | |
| <button class="this-button" id="click-me-once">Click Me!</button> | |
| <script id="jsbin-javascript"> | |
| var btn = document.querySelector('#click-me-once'); | |
| btn.addEventListener('click', function (event) { | |
| console.log(event); // The event details | |
| console.log(event.target); // The clicked element | |
| }, false); | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript">var btn = document.querySelector('#click-me-once'); | |
| btn.addEventListener('click', function (event) { | |
| console.log(event); // The event details | |
| console.log(event.target); // The clicked element | |
| }, false); | |
| </script></body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var btn = document.querySelector('#click-me-once'); | |
| btn.addEventListener('click', function (event) { | |
| console.log(event); // The event details | |
| console.log(event.target); // The clicked element | |
| }, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment