I'm trying to make a function that every time I click a button, add a value to a variable, and it shows on the screen but it does not work.
Any ideas on how to fix it?
<button onclick="myFunction()">Click me</button>
<p id="demo"></p>
<script>
var a = 0;
function myFunction() {
a = a + 1;
}
document.getElementById("demo").innerHTML = a;
</script>