Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increment/decrement the value of a field using jquery

Tags:

jquery

I am getting a wrong output when i alert this, it shows '01'

<input type="hidden" id="hidNavigation" name="hidNavigation" value="0" />

alert($("#hidNavigation").val($("#hidNavigation").val() + 1));

I am a newbie using jquery, please help me how to increment/decrement values in jquery.

Thanks, Nash

like image 399
nash Avatar asked Sep 02 '09 09:09

nash


2 Answers

alert($("#hidNavigation").val(parseInt($("#hidNavigation").val()) + 1));
like image 76
Darin Dimitrov Avatar answered Nov 04 '22 11:11

Darin Dimitrov


$("#hidNavigation").get(0).value++

Simply reposted from comment to @DarinDimitrov answer ... credits to @northamerican

like image 35
madzohan Avatar answered Nov 04 '22 11:11

madzohan