What is the shortest way in jQuery (or pure JavaScript) to increment the value of an input field?
For instance
<input id="counter" type="hidden" name="counter" value="1">
so it changes to
<input id="counter" type="hidden" name="counter" value="2">
Demo
OR
Demo
You can wrap any one of the above code within a function and call that for further increment. For example:
Now call
increment()when and where you need.