Getting the id of a table row when a checkbox is checked
<p>I have a checkbox inside a table row</p>

<pre><code>&lt;tr id="1"&gt;
&lt;td&gt;&lt;input type="checkbox" /&gt;&lt;/td&gt;
&lt;td&gt;lorem&lt;/td&gt;
&lt;td&gt;ipsum&lt;/td&gt;
&lt;td&gt;css&lt;/td&gt;
&lt;/tr&gt;
</code></pre>

<p>I want to get the id when the checkbox is checked</p>

<p>I have tried this</p>

<pre><code>var closestTr = $(':checkbox:checked').closest('tr').attr('id');

alert(closestTr);
</code></pre>

<p>I also tried this <a href="http://jsfiddle.net/AbfJk/3/" rel="nofollow">http://jsfiddle.net/AbfJk/3/</a></p>

<p>Why doesn't it get the id?</p>
