[jQuery] selecting next/prev element in a table

[jQuery] selecting next/prev element in a table


Hi list,
I have a number of checkboxes, each inside a table cell. I want to let
user navigate through these checkboxes using arrow keys. To do so I
start with a code like this:
$("input:checkbox").bind("keydown", function(e) {
// Here I want to find previous or next checkbox element
if (e.keyCode == 38) {
// select next
} else if () {
// select prev
}
});
How can I select (focus on) next or previous checkbox in a cell? there
might be different level of nesting for checkboxes, for example:
<table>
<tr>
<td>
[checkbox]
</td>
<td>
[checkbox]
</td>
<tr>
<td>
<span>[checkbox]<span>
</td>
<td>
[checkbox]
</td>
</tr>
</table>
Thanks,
Mohsen.