I’m messing with this simple line of code:
$(this).next('input').focus();
I’d like to get it to select the next (input OR textarea), whichever comes first – how can I do this?
As an alternative, how can I get it to simply focus on the next item in the tabindex?
Edit
Because the next input/tabindex is not always right after $(this), how can I easily traverse down the list of siblings until I find the next match?
Use
:inputwhich selects all input, textarea, select and button elements.jsFiddle
If the next input is not a sibling, this seems to work…
For this example, click in the textbox with the
id="test"and it willfocuson the next:inputelement.jsFiddle2