javascript – Looping tabindex on a div


The task of such an implementation in angular should be in the form of a controller or directive implementation:

    <input type="text" name="firstInput"/>
    <input type="text" name="secondInput"/>

there is a div with fields input[type='text'] it is necessary without leaving the div go through the input s, if after being on the last we click tab on the keyboard, then go back to the first input .


Alternatively, find all active elements (at least [tabindex], a[href], object, input, select, button ), save the value there and write -1 . When closing the dialog, return it as it was.

Another option is to handle tab pressing from your code and give focus to the desired element. I say right away that the reliability of this method is in question. And a case that requires a separate check is to click the address bar of the browser with the mouse and press tab there – this case will not fall under your handler and the question is purely about which element of the page will get the focus first.

Scroll to Top