0

I have this variable called counter that starts at zero. And I want to update it everytime the user clicks on a certain button

window.counter = 0;


jQuery("#someButton").click(function(){


    window.counter += 1;


})

So everytime the user clicks the button counter increase by 1.

Quinnystar27
  • 322
  • 1
  • 4
  • 14

1 Answers1

0

it already works... variable increases

https://jsfiddle.net/pouj1g92/

i added jsfiddle to test your self...

window.counter = 0;

$("#someButton").click(function(){
    window.counter += 1;
    alert(window.counter);
});
Barmar
  • 741,623
  • 53
  • 500
  • 612
S.P.
  • 45
  • 2
  • 7