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 );
Comments
Post a Comment