I'm trying to add or subtract 1 in an input but I can't finish it. the code I have is this:
onclick="$('#StockPagina').val($('#StockPagina').val()+1).change()"
this changes the value of the StockPagina input but adds a 1 to the end instead of adding one with what I am giving instead of putting 1,2,3,4 it puts me 01,011,0111
can't I just make it add one to the value that's there? Is there something like the ++ of php? If there is something like ++, is there also the -- to subtract?
Thank you very much for your help.
Test:
Remember that the value of the input is a string ; we have to convert it to a number before adding; if we don't, concatenate.
You need to convert the value of your
input
to a number to be able to execute mathematical operations on it, this is achieved with the JavaScript Number function