用jQuery模拟按Tab键

我在.net页面上有一些文本框,并希望通过jQuery实现以下内容:如果用户按返回,程序应该使用“好像”他已经使用Tab键,因此选择下一个元素。我尝试了以下代码(还有一些):
<script type="text/javascript">

jQuery(document).ready(function () {

    $('.tb').keypress(function (e) {
        if (e.keyCode == 13)
        {
            $(this).trigger("keydown",[9]);
            alert("return pressed");
        } 
    });
});
<asp:TextBox ID="TextBox1" runat="server" CssClass="tb"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" CssClass="tb"></asp:TextBox>

但它只是不工作!缺少一些东西,犯了错误

这里有一些我使用的链接

here

and here

解决方法

尝试这个:

http://jsbin.com/ofexat

$('.tg').bind('keypress',function(event) {
  if(event.which === 13) {
    $(this).next().focus();
  }
});

或循环版本:http://jsbin.com/ofexat/2

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...