Skip to content

Instantly share code, notes, and snippets.

@MrSnor
Created October 19, 2021 17:15
Show Gist options
  • Select an option

  • Save MrSnor/893d59afd0740a5b0be9aee59b301a7c to your computer and use it in GitHub Desktop.

Select an option

Save MrSnor/893d59afd0740a5b0be9aee59b301a7c to your computer and use it in GitHub Desktop.
<!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