Pergunta

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.

Foi útil?

Solução

Perhaps because #donaton should be #donation?

Outras dicas

var donation = parseInt($('#donation').val(), 10);

http://jsfiddle.net/U96F3/1/

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top