<button>+1</button>
<span></span>
<style>
button {
background-color: skyblue;
border-radius: 1rem;
}
</style>
<script>
const el = document.querySelector("button");
el.addEventListener('click', add);
let counter = 0;
function add() {
counter = counter + 1;
document.querySelector("span").textContent = counter;
}
</script>
index.html