Reputation: 121
I have found this: jQuery - Increase the value of a counter when a button is clicked and this JQuery Mouse Click counter
but does not work by me, i have tried this:
$("#btnplus").click(function(){
count =count +1;
$("#counterbox").html(count);
});
I have here a button and input box, button has id "btnplus" and input field "counterbox", i want if i clic on button to increase value of input, always +1, i don't get any error, what is here wrong?
Upvotes: 0
Views: 1633
Reputation: 283
var count = 0;
$("#btnplus").click(function () {
count = count + 1;
$("#counterbox").val(count);
});
Upvotes: 1
Reputation: 1260
Try this
var count;
$("#btnplus").click(function(){
count =count +1;
$("#counterbox").html(count);
});
i think this should be work.
Upvotes: 2