Created
January 7, 2020 02:41
-
-
Save colabottles/7db966b4f8d46391bf81783967a636f9 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> | |
| <style id="jsbin-css"> | |
| div { | |
| display: grid; | |
| justify-content: center; | |
| } | |
| button { | |
| display: flex; | |
| border: 2px solid black; | |
| background: none; | |
| padding: 0.75rem; | |
| justify-content: center; | |
| width: 24ch; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div> | |
| <button class="this-button" id="click-me-once">Click Me!</button> | |
| </div> | |
| <script id="jsbin-javascript"> | |
| var btn = document.querySelector('#click-me-once'); | |
| btn.addEventListener('click', function (event) { | |
| console.log(event); | |
| console.log(event.target); | |
| }, 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); | |
| console.log(event.target); | |
| }, 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
| div { | |
| display: grid; | |
| justify-content: center; | |
| } | |
| button { | |
| display: flex; | |
| border: 2px solid black; | |
| background: none; | |
| padding: 0.75rem; | |
| justify-content: center; | |
| width: 24ch; | |
| } |
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); | |
| console.log(event.target); | |
| }, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment