Suppose I have the following counter:
<button class="btn btn-primary" type="button">
Curtir <span class="badge"> 4 </span>
</button>
I want to apply this code below:
function criaCounter(init) {
var count = init || 0;
return function() {
count++;
alert(count);
}
}
$('#addCount').click(criaCounter(5));
so that it does not send an alert but increase the number next to the button to enjoy, always adding infinitely td time that someone clicks.