3
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 increases the number next to the like button, always adding infinitely td once someone clicks.
There is only one
<span class="badge"> 4 </span>
on the page?– Sergio
True, well remembered. are various on the page, each new post a 0 zeroed counter with the like button begins. to weigh in using that of the same faceboo.
– Phreak Jr
Okay, if there are several you need to take that into account. I’ll give you an answer too, but I still don’t know what the
'#addCount'
... can you explain the idea? is to show the count?– Sergio