Javascript 浮点数与parseFloat的乘积返回NaN
我想得到当前计数的0.6,然后显示Math.float。但是南回来了Javascript 浮点数与parseFloat的乘积返回NaN,javascript,jquery,Javascript,Jquery,我想得到当前计数的0.6,然后显示Math.float。但是南回来了 $('.unemployed.count').html((Math.floor(parseFloat('0.6')*parseFloat($($('.unemployed.count').text())))).toString(10)); Html看起来像这样 <div id='population'> <table id='population_data'>
$('.unemployed.count').html((Math.floor(parseFloat('0.6')*parseFloat($($('.unemployed.count').text())))).toString(10));
Html看起来像这样
<div id='population'>
<table id='population_data'>
<tr tooltip='Unemployed citizens'>
<td>Unemployed</td>
<td class='unemployed count'>2</td>
</tr>
<tr tooltip='Employed citizens'>
<td>Employed</td>
<td class='employed count'>2</td>
</tr>
</table>
</div>
我做错了什么?
谢谢问题就在这里
parseFloat($($('.unemployed.count').text()))
试试这个:
$('.unemployed.count').html((Math.floor(parseFloat('0.6')*parseFloat(
$('.unemployed.count').text()))) // problem is in this line
.toString(10));
而不是
$('.unemployed.count').html((Math.floor(parseFloat('0.6')*parseFloat(
$($('.unemployed.count').text()))))
.toString(10));