user2496077
user2496077

Reputation: 121

jQuery input field value with counter

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

Answers (2)

Rajeev.Ranjan
Rajeev.Ranjan

Reputation: 283

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

Upvotes: 1

Rakesh Singh
Rakesh Singh

Reputation: 1260

Try this

var count;

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

i think this should be work.

Upvotes: 2

Related Questions