This article provides a jquery implementation of Enter and enter switch focus code, let's take a look here.
<script type= "text/web Effects" >
$ (function () {
$ (' Input:text:first '). focus ();
var $inp = $ (' Input:text ');
$inp. Bind (' KeyDown ', function (e) {
var key = E.which;
if (key = = 13) {
E.preventdefault ();
var nxtidx = $inp. Index (this) + 1;
$ (": Input:text:eq (" + Nxtidx + ")"). focus ();
}
});
});
</script>
HTML code
<div>
<asp Tutorial: TextBox id= "Txt1" runat= "Server"/><br/>
<asp:textbox id= "txt2" runat= "Server"/><br/>
<asp:textbox id= "TXT3" runat= "Server"/><br/>
<asp:textbox id= "TXT4" runat= "Server"/><br/>
</div>
Instance two implement enter key to toggle focus jquery Code
<div>
<asp:textbox id= "TB1" runat= "Server" class= "CLS"/><br/>
<asp:textbox id= "TB2" runat= "Server" class= "CLS"/><br/>
<asp:textbox id= "Tb3" textmode= "Multiline" runat= "Server" class= "CLS"/><br/>
<asp:textbox id= "TB4" runat= "Server" class= "CLS"/><br/>
</div>
<script type= "Text/javascript" >
$ (function () {
$ (' Input:text:first '). focus ();
var $inp = $ ('. CLS ');
$inp. Bind (' KeyDown ', function (e) {
var key = E.which;
if (key = = 13) {
E.preventdefault ();
var nxtidx = $inp. Index (this) + 1;
$ (". Cls:eq (" + Nxtidx +) "). focus ();
}
});
});
</script>