弹出DivTD使用jQuery获取值

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (89)

下面是我试图在弹出窗口中显示的div。如何从弹出窗口中获取td值。当试图调用popupClick()时,它返回未定义的。我已经附上了下面的代码。

<div class="modal1-body" style="height:400px;overflow-y:auto;">
                <br />
                <div class="col-md-12 container-fluid">
                    <table id="smartresultTable" class="table table-striped table-bordered smartresultClass">
                        <thead style="text-align:center;background-color:cadetblue;color:white;">
                            <tr>
                                <td>ClaimSummaryID</td>
                                <td>PatientName</td>
                                <td>PayorName</td>
                                <td>ProviderName</td>
                                <td>TotalPaid</td>
                            </tr>
                        </thead>
                        <tbody style="text-align:center;"></tbody>
                    </table>
                </div>
            </div>

    function btnSmartResult() {
            $.ajax({
                dataType: "json",
                url: "/Rule/SmartResultExecution",
                //datatype: "text",
                type: "POST",
                success: function (data) {
                    $('#smartresultTable tbody').empty();


                    $.each(JSON.parse(data), function (index, jsonResult) {
                        console.log(jsonResult.CurrentClaimIPID);
                        var rows = "<tr>" + "<td class='smartresultId'  onclick='popupClick();'><a href='#'>" + jsonResult.ClaimSummaryId + "</a></td>" + "<td>" + jsonResult.PatientName + "</td>" + "<td>" + jsonResult.PayorName + "</td>"
                            + "<td>" + jsonResult.ClientDemographicMasterID + "</td>" + "<td>" + jsonResult.AmountPaid + "</td>" + "</tr>";
                        $('#smartresultTable tbody').append(rows);
                    });
                var modal = document.getElementById('ruleSmartResultPopup');
                modal.style.display = "block";
            },
            error: function (data) { }
        });
    }



 function popupClick() {

        var obj = { claimSummaryID: parseInt($(this).closest("tr").find("td").eq(0).html()) };
        alert($(parseInt($(this).closest("tr").find("td").eq(0).html())));
    }
提问于
用户回答回答于
function btnSmartResult() {
            $.ajax({
                dataType: "json",
                url: "/Rule/SmartResultExecution",
                //datatype: "text",
                type: "POST",
                success: function (data) {
                    $('#smartresultTable tbody').empty();

                    $.each(JSON.parse(data), function (index, jsonResult) {
                        console.log(jsonResult.CurrentClaimIPID);
                        var rows = "<tr>" +
                        "<td class='smartresultId' id='" + jsonResult.ClaimSummaryId + "' onclick='popupClick(this.id);'><a href='#'>" + jsonResult.ClaimSummaryId + "</a></td>" +
                        "<td>" + jsonResult.PatientName + "</td>" +
                        "<td>" + jsonResult.PayorName + "</td>"
                        +
                        "<td>" + jsonResult.ClientDemographicMasterID + "</td>" +
                        "<td>" + jsonResult.AmountPaid + "</td>" +
                    "</tr>";
                        $('#smartresultTable tbody').append(rows);
                    });
                    var modal = document.getElementById('ruleSmartResultPopup');
                    modal.style.display = "block";
                },
                error: function (data) { }
            });
        }



        function popupClick(value) {
            alert(value);
        }

扫码关注云+社区

领取腾讯云代金券