---
title: "tab键的焦点始终在一个层里面"
author: "tdmlxq"
date: "2010-05-06T17:24:04Z"
tags: []
categories: ["Web前端"]
slug: "tab"
draft: false
lastmod: "2010-05-06T17:24:04Z"
id: 660571
url: "https://tdmlxq.iteye.com/blog/660571"
---

```
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Untitled Document</title>
        <script type="text/javascript" src="./javascripts/jquery-1.4.2.js"></script>
        <script type="text/javascript">
            $(function(){
                $('.modeDiv input:last').keydown(function(e){
                    if (e.keyCode == 9) {
                        $('.modeDiv input:first').focus();
                        return false;
                    }
                });

            });
        </script>
    </head>
    <body>
        <div class="modeDiv">
            <form action="#" method="post">
                <table class="login_table">
                    <tr>
                        <td>用户名：</td>
                        <td>
                            <input id="username" type="text" size="30" name="username" value="">
                        </td>
                    </tr>
                    <tr>
                        <td>密码：</td>
                        <td>
                            <input id="password" type="password" size="30" name="password" value="">
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" class="align_right">
                            <input id="login" type="button" value="登录" />
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </body>
</html>
```