0

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?

Community
  • 1
  • 1
user2496077
  • 121
  • 1
  • 7

2 Answers2

2

Try this

var count;

$("#btnplus").click(function(){
count =count +1;
$("#counterbox").html(count);
});

i think this should be work.

Rakesh Singh
  • 1,250
  • 9
  • 8
1
var count = 0;
$("#btnplus").click(function () {
count = count + 1;
$("#counterbox").val(count);
});
Rajeev.Ranjan
  • 273
  • 1
  • 3
  • 14