我想获得当前计数的0.6,然后显示Math.float。但是NaN被退回了
$('.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>
我做错了什么? 感谢
答案 0 :(得分:0)
答案 1 :(得分:0)
试试这个:
$('.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));
<强> DEMO 强>