如何在使用javascript按Enter后继续关注下拉列表。我已经编写相同的代码,但重点是文本框以及稍后的dropdownlist.But我希望首先关注下拉列表,然后是文本框。任何人都可以告诉我哪里出错了。这是我的代码:
<script type="text/javascript" src="msdropdown/js/jquery-1.4.2.min.js">
</script>
<script type="text/javascript">
$(document).ready(function () {
$('input:text:first').focus();
var $inp = $('.cls');
var n = $inp.length;
$inp.bind('keydown', function (e) {
var key = e.which;
if (key == 13) {
e.preventDefault();
var nxtIdx = $inp.index(this) + 1;
if(nxtIdx < n)
$(".cls:eq(" + nxtIdx + ")").focus();
else {
$(".cls:eq(" + nxtIdx + ")").blur();
}
}
});
});
</script>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="STATUS" DataValueField="STATUS"
Width="70px" CssClass="cls">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server"
DataSourceID="SqlDataSource1" DataTextField="STATUS" DataValueField="STATUS"
Width="70px" CssClass="cls">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList3" runat="server"
DataSourceID="SqlDataSource1" DataTextField="STATUS" DataValueField="STATUS"
Width="70px" CssClass="cls">
</asp:DropDownList>
<asp:TextBox ID="TextBox1" runat="server" Width="70px"
CssClass="cls"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"
Width="70px" CssClass="cls"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server" Width="70px"
CssClass="cls"></asp:TextBox>