Created
October 19, 2021 17:15
-
-
Save MrSnor/893d59afd0740a5b0be9aee59b301a7c to your computer and use it in GitHub Desktop.
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>Personal expense</title> | |
| <style> | |
| body { | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| height: 100vh; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <button id="btnCounter">+</button> | |
| <script> | |
| // Get the btn element | |
| const element = document.querySelector("#btnCounter"); | |
| // Listen to click event | |
| element.addEventListener("click",counterIncrement, false); | |
| // Take a number starting from o | |
| let counter = 0; | |
| // function to increment the number | |
| function counterIncrement() { | |
| // Every click increment a number | |
| counter = counter + 1 ; | |
| console.log(counter); | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment