我已经在分钟的格式设置的三次时间:秒:毫秒,我需要以加在一起,并获得总时间..添加行值
例如我用的一个是:0:31.110 + 0:50.490 + 0:32.797 其中= 1:54.397
所以如何做到这一点在JavaScript?
这里是JS代码
var sp1 = $('#table tr td:nth-child(2)').text()
var sp2 = $('#table tr td:nth-child(3)').text()
var sp3 = $('#table tr td:nth-child(4)').text()
var1 = sp1 + sp2 + sp3
$('td:nth-child(5)').html(var1);
我不知道从哪里开始,但我刚刚想出了上面的代码.. 我需要的输出为1:在过去的54.397 td,但是我得到这个例子中显示的0:31.1100:50.4900:32.797 http://jsfiddle.net/q1kumbea/
以及您希望阵列添加尽可能多的数字,你可以简单地用分割法打破它和做数学题 – aw04
你需要拆分时间,然后单独添加每个组件,如t1.split(“:”),t2.split(“:”),t3.split(“:”),然后t1 [0] + t2 [0] + t3 [0 ] ...并在结尾再次加入冒号(:) – atul