tags:

views:

41

answers:

1

From the change event of a textbox in a td, I want to find a div whose classname = 'licenseStatus' in another cell within the row in which the textbox resides but can't seem to figure it out...

$('#gridRequestedApps .xxxAppName').change(function() {
   var licenseOutputCell = $(this).parent('tr').find(".licenseStatus");
   alert(licenseOutputCell.text());    // is an empty string
});
+1  A: 

You may need to use the parents() function:

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

parents("tr:first") works because you're selecting the first TR ancestor element, and not a direct parent which is what parent() does.

David Andres