Perhaps because #donaton
should be #donation
?
Pulling value from form, then converting text to integer [closed]
-
25-06-2022 - |
Question
I've been trying to use jQuery to pull a variable from my form (as a string) and then convert it into a number to have it added to other variables. Instead, NaN is displayed.
<input type="text" name="donation" id="donation" value="0">
var donation = parseInt(form.find('input[text=donation]'), 10);
Used jQuery in the past, but still new to some aspects. Any help is appreciated.
Solution
OTHER TIPS
var donation = parseInt($('#donation').val(), 10);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow