This code is supposed to find all table rows with a class of "selected", remove that class, then find all checked inputs that are descendants of a tr and give its tr a class of selected. The problem is, that even radio boxes that are not checked are being returned by $(' tr input:checked', '#deviceSelection') and everything is getting a class of selected. Anyone know whats wrong? I'm using jQuery 1.4.1
<script>
function updateSelectedRows() {
$(' tr .selected', '#deviceSelection').removeClass('selected');
$(' tr input:checked', '#deviceSelection').closest('tr').addClass('selected');
}
$('input:radio, input:checkbox').live('change', updateSelectedRows);
</script>
<tbody id="deviceSelection">
<tr class="odd">
<td><input id="deviceGroupIdSelector" name="deviceGroupIdSelector" value="2" type="radio"></td>
</tr>
<tr>
<td><input id="deviceGroupIdSelector" name="deviceGroupIdSelector" value="1" type="radio"></td>
</tr>
</tbody>