如何分割小数?变量bidnumber10.70

var bidnumber = $(this).parent('div').siblings('.advert-details').find('tr:eq(3)').find('.advert-details-col-2').attr('data-bid');
bidnumber.toString().split('.');
var first = bidnumber[0];
var second = bidnumber[1];
alert(bidnumber[0]);
second.substr(0, 1);
var finalnumber = first + '.' + second;


当我提醒bid[0]时,它应该提醒10。相反,会提醒1。我不知道哪里出了问题?

最佳答案

您忘记了从split函数返回数组:

bidnumber = bidnumber.toString().split('.');

07-26 05:40