javascript - Jquery focus on next td element with an input child -


i have table tr , td elements so.

<tr>   <td><input type="text"></td>   <td><input type="text"></td>   <td></td>   <td></td>   <td><input type="text"></td> </tr> 

some tds have input elements , don't. using jquery, how focus next input while skipping td's without input fields?

i have tried this: $(':focus').parent().next("td:has(input)").focus();

with no success.

the end goal able use keybindings have created cycle forwards , backwards through inputs without using 'tab' key.

.next checks element's immediate next sibling, not check of successive siblings.

if want check of it's siblings, 1 solution first element of .nextall

$(':focus').parent().nextall("td:has(input)").eq(0).focus(); 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -