开发者

jQuery rounding problem with .val()

开发者 https://www.devze.com 2022-12-10 04:11 出处:网络
I have a textbox where a user inputs a number, like: 105.14 When开发者_如何学Go I use jQuery to read it:

I have a textbox where a user inputs a number, like: 105.14 When开发者_如何学Go I use jQuery to read it:

alert(parseInt($("#Info").val()));

It displays "105".

Why can't I get the remaining .14????

I'm sure it's something obvious....


This is because you are using parseInt(), which is rounding.

Try parseFloat() instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消