Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript的浮点和(jquery)_Javascript_Jquery_Sum - Fatal编程技术网

使用javascript的浮点和(jquery)

使用javascript的浮点和(jquery),javascript,jquery,sum,Javascript,Jquery,Sum,我有jquery代码,但我希望每秒的值为+0.00001 $document.readyfunction{ 设置间隔函数 { 变量id=$'.id'.attr'rel'; var st=parseFloatid+parseFloat'0.00001'.toFixed1; $'.id'.htmlst; $'.id'.attr'rel',st; }, 1000; }; //html输出 0.00001这个问题是因为使用toFixed1四舍五入到小数点后1位。将其更改为toFixed5,代码就可以

我有jquery代码,但我希望每秒的值为+0.00001

$document.readyfunction{ 设置间隔函数 { 变量id=$'.id'.attr'rel'; var st=parseFloatid+parseFloat'0.00001'.toFixed1; $'.id'.htmlst; $'.id'.attr'rel',st; }, 1000; }; //html输出
0.00001这个问题是因为使用toFixed1四舍五入到小数点后1位。将其更改为toFixed5,代码就可以正常工作。尽管请注意,将字符串文字转换为浮点有点多余,但只需在加法中直接使用浮点:

$document.readyfunction{ 设置间隔函数{ 变量id=$'.id'.attr'rel'; var st=parseFloatid+0.00001.toFixed5; $'.id'.htmlst.attr'rel',st; }, 1000; }; //html输出
0.00001对,那么你的问题是什么?toFixed1正在压缩你的小数点后5位,为什么你硬编码浮点0.00001'-只有0.00001有什么问题吗?谢谢Rory McCrossan