Use jQuery to override the default action of the TAB key inside an element?
I have two text field boxes; username and password. There is also a checkbox below the username field. Currently pressing the tab button on they keyboard results in the checkbox gaining focus, I would like to override this so that tab key would bring开发者_如何学Python the password field into focus. Does anyone know how to do this using jQuery or how to restructure the HTML to achieve the same effect? Thanks
Use tabindex
<input type="text" name="user" tabindex=1 /><br />
RemberMe:<input type="checkbox" name="loggedIn" value=" " /><br />
<input type="password" name="password" tabindex=2 /><br />
<input type="text" name="user" tabindex=1 /><br />
<input type="password" name="password" tabindex=2 /><br />
RemberMe:<input type="checkbox" name="loggedIn" tabindex=3 /><br />
or
<input type="text" name="user" tabindex=1 />
RemberMe:<input type="checkbox" name="loggedIn" tabindex=3 /><br />
<input type="password" name="password" tabindex=2 /><br />
tab index is the attribute to shift focus when tab is clicked.
精彩评论