Is there a better way to get values out of a table row?
<p>Say I have this</p>

<pre><code>&lt;table border="1" id="tbl"&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type="checkbox" name="vehicle" value="Bike" /&gt;&lt;/td&gt;
&lt;td&gt;row 1, cell 1&lt;/td&gt;
&lt;td&gt;row 1, cell 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type="checkbox" name="vehicle" value="Bike" /&gt;&lt;/td&gt;
&lt;td&gt;row 2, cell 1&lt;/td&gt;
&lt;td&gt;row 2, cell 2&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt; 
</code></pre>

<p>Now I want to get the row that is checked, then the cell values of that checked row. So I would do this</p>

<pre><code> var cells = $('#tbl :checked').parents('tr').children('td');
</code></pre>

<p>So lets assume only one checkbox can be checked(so no jQuery foreach loop).</p>

<p>So now say I wanted to get the 2nd table cells value I would just go</p>

<pre><code>var secondCell = $(cells[1]).html();
</code></pre>

<p>The thing with this though it makes the code so brittle. Like what if I put another table cell after after the checkbox one?</p>

<pre><code>&lt;table border="1" id="tbl"&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type="checkbox" name="vehicle" value="Bike" /&gt;&lt;/td&gt;
   &lt;td&gt; I am new &lt;/td&gt;
  &lt;td&gt;row 1, cell 1&lt;/td&gt;
  &lt;td&gt;row 1, cell 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type="checkbox" name="vehicle" value="Bike" /&gt;&lt;/td&gt;
   &lt;td&gt; I am new &lt;/td&gt;
  &lt;td&gt;row 2, cell 1&lt;/td&gt;
  &lt;td&gt;row 2, cell 2&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt; 
</code></pre>

<p>So now I have to go through my code and change this </p>

<pre><code>var secondCell = $(cells[1]).html();
</code></pre>

<p>to  this</p>

<pre><code>var thirdCell = $(cells[2]).html();
</code></pre>

<p>Since now I am actually after the 3rd cell and not the 2nd cell anymore.</p>

<p>So is there a better way?</p>

<p>Thanks</p>
