title: Looping through table and changing values in jQuery
body: <p>This is my tablestructure in jsp</p>
  
  <pre><code>&lt;table id="servicetable"&gt;
  &lt;tr&gt;
  &lt;td colspan="2"&gt;&lt;label id="servicename"&gt;somelabel&lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;label id="status"&gt;RUNNING &lt;/label&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td colspan="2"&gt;&lt;label id="servicename2"&gt;somelabel&lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;label id="status"&gt;RUNNING &lt;/label&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td colspan="2"&gt;&lt;label id="servicename3"&gt;somelabel&lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;label id="status"&gt;RUNNING &lt;/label&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Now I have to change the value of "RUNNING" to "STOPPED" if my value of "servicename" first td matches another string. Below is the code</p>
  
  <pre><code>     var $all_td_in_a_table = $("#servicetable td:nth-child(1)");//to get all first td's
  
                    $all_td_in_a_table.each(function(){                  
                         labelText_servicename = $("#servicename").text();
                         labelText_servicename=$.trim(labelText_servicename);
                         if(labelText_servicename.toLowerCase() ==="ABC"){
                         labelText = $("#status").text();
                         $("#status").text("TEST");
                         }
  });
  </code></pre>
  
  <p>I see the variable "all_td_in_a_table" has list of all first td's, but my .each loop is always giving me the first td. Please help.</p>