Here’s a cool jQuery snippet that you can use to create a click counter. The way it works is that each time an element is clicked, the counter (which starts at 0) goes up by one. The counter can be applied to the clicking of any particular elements or multiple elements, and you can choose whether or not to display it somewhere on your page or site, or log the counter to the console, or use the counter in a function.
The code for creating a counter isn’t too complicated and shouldn’t be more than a handful of lines of code. While it doesn’t have to be a counter that is triggered by a click (it could be triggered by any number of events), in this particular example, it is a click counter. Feel free to customize the code so that its functionality appeals to you and so that it works with your HTML and with your desired elements.
// begin counter at zero
counter = $(
, counter + 1);
// do something else...