Help getting relative elemet

Help getting relative elemet

Hi experts.
I am pretty new to jQuery so go easy on me.

Using the following HTML:

<table border="1">
 <tr>
  <td headers="QTY">
  <input type="text" name="f01">
  <input type="hidden" name="f50" value="1">
  </td>
 </tr>
 <tr>
  <td headers="QTY">
  <input type="text" name="f01">
  <input type="hidden" name="f50" value="0">
  </td>
 </tr>
</table>

I am trying to do the following:

1. For each row
2. look at the value of the hidden item "f50"
3. If the value = 1 then set the background color of f01 to green
4. If the value != 1 then set the background color of f01 to yellow

So far, I have this:

$('input[name="f50"]').each
(
 function(index)
 {
  var theItem = this;
  
  if (parseInt(theItem.value) == 1)
  {
      alert ('Make Green');
  }
     else
     {
        alert ('Make Yellow');
     }
     
 }
);

I am not sure how I reference the relative f01 element from where I am.

Any help is much appreciated.

Cheers

Duncs