I'm having a problem, how to get a number of clicks on a button in jQuery?
I am familiar with javascript code, so any help would be useful.
I'm having a problem, how to get a number of clicks on a button in jQuery?
I am familiar with javascript code, so any help would be useful.
You have to create a variable outside of the function scope so it doesn't get reset each time the function is called.
var counter = 0;
function add()
{
counter++;
console.log("Button has been clicked", counter, "times(s)");
}
<button onclick="add()">Click me!</button>