开发者

Use jQuery to override the default action of the TAB key inside an element?

开发者 https://www.devze.com 2023-01-17 12:59 出处:网络
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 l

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消