jquery Tree Traversal prev() in TD's
- by Guido Lemmens
Hello,
I'm trying to check/unckeck a selectbox by jquery in a previous TD. I have tried for hours several combination with prev(), parent(), closest(), but still without result... Here is the example code:
<table>
<tr>
<td><input type="checkbox" class="resultcheck"></td>
<td><label class="resultchecklabel">Text 1</label></td>
</tr>
<tr>
<td><input type="checkbox" class="resultcheck"></td>
<td><label class="resultchecklabel">Text 2</label></td>
</tr>
</table>
<script>
$('.resultchecklabel').live('click', function() {
if ($(this).prev('td input:checked').val() != null)
{
$(this).prev('td').prev("input").removeAttr("checked");
}
else
{
$(this).prev('td').prev("input").attr("checked","checked");
}
});
</script>
Who can help me to solve this question?
Many thanks!