我在text输入0.1 为什么取到的值总是0

解决方案 »

  1.   

    var input = "0.1";
    var num = parseFloat(input);
    alert(num);
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript">
    function show(a){
    alert(a.value);
    }
    </script>
    </head><body>
    <textarea id="test" onblur="show(this)"></textarea>
    </body>
    </html>
    没有啊
      

  3.   

    贴代码吧,js取不应该会自动取整的。
    后台的话用int取肯定会舍掉小数点后的,需要double取
      

  4.   

    楼主应该是用了parseInt了