天天看点

Jquery 表格单元 遍历 计算

有时我们需要通过访问 表格内单元 内容进行 数据处理,比如下面就是通过计算 表格 的 欠费余额单元格的总和 为应缴费总额的

Jquery 表格单元 遍历 计算
//重新计算欠费总额,应交
    function Recount() {
        padiRoomIdList = "";
        //
        var unPaidTotal = 0;
        var shouldPadiThisPeriod = 0;
        $('[flag=Select]:checked').each(function () {
            unPaidTotal = unPaidTotal + parseInt($(this).parents("tr").children('td').eq(8).text());
            
            if (padiRoomIdList != "") {
                padiRoomIdList += ",";
            }
            padiRoomIdList += $(this).attr("key");
        });

        $("#unPaidTotal").numberbox("setValue", unPaidTotal);
        if (unPaidTotal != 0) {

            $("#chargeNum").select();
            $('#bt_charge').removeAttr("disabled");
        }

    }
           

附加:

根据前一个单元格的内容设置后面的按钮是否有效

Jquery 表格单元 遍历 计算

  //屏蔽已经发送短信的记录

                        $('#workList2>table tr').each(function () {

                            if ($(this).children('td').eq(4).text() != "") {

                                $(this).children('td').eq(5).children("input").eq(0).attr("disabled", true);

                            }

                        });

附加2:天数超过=3天的记录加黄色底

Jquery 表格单元 遍历 计算

   $('#display_area>table tr').each(function () {

                    if (parseInt($(this).children('td').eq(6).text()) >= 3) {

                        $(this).addClass('attation');

                    }

                });