代码之家  ›  专栏  ›  技术社区  ›  tbone

如何在表行的另一个单元格中按类名查找元素?

  •  0
  • tbone  · 技术社区  · 15 年前

    $('#gridRequestedApps .xxxAppName').change(function() {
       var licenseOutputCell = $(this).parent('tr').find(".licenseStatus");
       alert(licenseOutputCell.text());    // is an empty string
    });
    
    1 回复  |  直到 15 年前
        1
  •  1
  •   David Andres    15 年前

    您可能需要使用 parents() 功能:

    $("#gridRequestedApps .xxxAppName").change
    (
      function()
      {
        var licenseOutputCell = $(this)
                                  .parents("tr:first")
                                  .find("div.licenseStatus");
        alert(licenseOutputCell.text());
      }
    );
    

    parents("tr:first") parent()