开发者

jquery table rows calculation

开发者 https://www.devze.com 2023-02-22 07:35 出处:网络
Here is table code... <tr> <td class=\"installationcharge\">500</td> <td class=\"supportcharge\">300</td>

Here is table code...

<tr>
<td class="installationcharge">500</td>
<td class="supportcharge">300</td>
<td class="totalcharges">800</td>
</tr>
    <tr>
<td class="installationcharge">200</td>
<td class="supportcharge">400</td>
<td class="totalcharges">600</td>
</tr>
<tfoot>
<tr><td>Total :</td>
<td class="totalinstcharges"></td>
<td class="totalsuppcharges"></td>
&l开发者_运维百科t;td class="totalchartotal"></td>
</tr>
</tfoot>

I am trying to calculate and post of all installationcharge, supportcharge, totalcharges in their tfoot total td. I have tried to use jquery each function but no luck, can you help out please. thanks.


var sum1 = 0;
$('.installationcharge').each(function(){
  sum1+= parseFloat($(this).html());
});

$('.totalinstcharges').html(sum1);

and for other data in the same way.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号