9 Replies
why i cant += input value
but i can do this
moneygetterhaha.value -= 1 ;
moneygetterhaha.value *= 2 ;
moneygetterhaha.value /= 2 ;
how can i fix the moneygetterhaha.value += 1;
because the + sign also is a way to concatenate strings. as the value of an input is a string, it will append the 1, not add it up.
these options should work
-
moneygetterhaha.value = Number(moneygetterhaha.value) + 1
- moneygetterhaha.value = moneygetterhaha.valueAsNumber + 1
- moneygetterhaha.value = +moneygetterhaha.value + 1
- moneygetterhaha.value++
(only works with adding up 1)tnx so much
it work
i stuck in it for 1 hours
the other operations don't have double functions, so JS knows it has to be converted to a number
so only for + this happen
indeed
it's just better if u do
.valueAsNumber
u won't have to face all these issues
you can't update the value of an input with valueAsNumber directly.
ooh dang.. makes sense
tnx