首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >popup Div td使用Jquery获取值

popup Div td使用Jquery获取值
EN

Stack Overflow用户
提问于 2018-05-31 19:24:57
回答 2查看 289关注 0票数 0

下面是我试图在弹出窗口中显示的div。如何从弹出窗口获取TD值。当尝试调用popupClick()时。它返回未定义的。我已经附上了下面的代码。提前感谢你的帮助。

代码语言:javascript
复制
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())));
    }
代码语言:javascript
复制
<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>

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-05-31 20:03:35

尝尝这个

代码语言:javascript
复制
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);
        }
票数 0
EN

Stack Overflow用户

发布于 2018-05-31 20:36:46

您应该使用.text()而不是.html()

您的代码将是:

代码语言:javascript
复制
function popupClick() {

        var obj = { claimSummaryID: parseInt($(this).closest("tr").find("td").eq(0).html()) };
        alert($(parseInt($(this).closest("tr").find("td").eq(0).text()))); //<--Changed .html() to .text()
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50623191

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档