title: Simulate pressing tab key with jQuery
body: <p>I have some textboxes on a .net-page and want to achieve the following with jQuery: if the user presses return, the program should behave "as if" he had used the tab key, thus, selecting the next element. I tried the following code (and some more):</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  jQuery(document).ready(function () {
  
      $('.tb').keypress(function (e) {
          if (e.keyCode == 13)
          {
              $(this).trigger("keydown", [9]);
              alert("return pressed");
          } 
      });
  });
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;asp:TextBox ID="TextBox1" runat="server" CssClass="tb"&gt;&lt;/asp:TextBox&gt;
  &lt;asp:TextBox ID="TextBox2" runat="server" CssClass="tb"&gt;&lt;/asp:TextBox&gt;
  </code></pre>
  
  <p>but it just does not work! Missing something, making a mistake?</p>
  
  <p>Here some links I used</p>
  
  <p><a href="https://stackoverflow.com/questions/832059/definitive-way-to-trigger-keypress-events-with-jquery">here</a></p>
  
  <p><a href="https://stackoverflow.com/questions/807083/how-to-send-a-keypress-trigger-using-jquery">and here</a></p>