selecting elements by value

selecting elements by value

Hi All,

I'm new to jquery so pardon my ignorance but is there an easy way to select a hidden field by it's value? I have a table with multiple rows:

  1. <row> hidden field (serial number) + checkbox + label
  2. <row> hidden field (serial number) + checkbox + label
  3. <row> hidden field (serial number) + checkbox + label
  4. <row> hidden field (serial number) + checkbox + label
  5. <row> hidden field (serial number) + checkbox + label

I've got a function which takes in a serial number and I want to find the label corresponding to it and set it's value. This is what I have currently:

  1.         $("input:hidden[@value='" + serialNumber + "']").each(function () {
  2.             // update status - this is sibling to the hidden field
  3.             $(this).siblings("span[@name *= 'lblFeedback']").each(function () {
  4.                 this.innerText = resultFeedback;
  5.             });
  6.         });

But unfortunately this returns all hidden fields. Is there a nice way of doing using selectors or is the only way to do this like this:

  1.         // find the hidden field with that serial number
  2.         $("input:hidden").each(function () {
  3.             if ($(this).val() == serialNumber) {
  4.             
  5.                 // update status - this is sibling to the hidden field
  6.                 $(this).siblings("span[@name *= 'lblFeedback']").each(function () {
  7.                     this.innerText = resultFeedback;
  8.                 });
  9.             }
  10.         });
Thanks
Sidharth