jquery - How to get value from input element as a number in decimal -


i wnat values input elements numbers , count them jquery. i'm trying, result not on decimal. how fix problem ?

html

<input name="test1" value="1.77" type="hidden" /> <input name="test2" value="1.23" type="hidden" /> 

jquery

var = parseint($( "input[name='test1']").val(), 10); var b = parseint($( "input[name='test2']").val(), 10); alert( + b ); // should 3, 2 

here example -> jsfiddle example

use parsefloat decimals , not parseint (which integers)!

e.g.

var = parsefloat($( "input[name='test1']").val(), 10); var b = parsefloat($( "input[name='test2']").val(), 10); var c = ( + b );  $('#result').append( c ); 

jsfiddle: http://jsfiddle.net/trueblueaussie/87tdj7z3/5/


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -