How to set focus to the input box in a table using jQuery
I am trying to set focus to the next input element in a table when onkeyup event is triggered, much similar to the functionality as stated here
<table&g开发者_高级运维t;
<tr>
<ui:repeat value="#{alphabets}" var="alphabet">
<td>
<h:inputText value="#{alphabet.value}" onkeyup="jumpNext(this)" />
</td>
</ui:repeat>
</tr>
</table>
The script $(input).next("input[type=text]").focus();
is not working if input elements are inside the table. And i also tried the following script
$(input).closest('td').next('td').find('input[type=text]').focus();
but couldn't able to get the expected behavior.
How to do this?
I would use:
$( 'input[type=text]', $('input').parent().next('td') ).focus();
If you don't have other inputs don't bother filtering by type
精彩评论