2345

日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

ASP.NET jQuery 食譜2 (表單中使用回車在TextBo

系統 2461 0

每次當用戶在一個文本框輸入完數據后,更希望在敲入回車鍵后,焦點會自動移動到下一個文本框。

通過下面的代碼可以實現這種切換的效果。

首先我們來看界面:

ASP.NET jQuery 食譜2 (表單中使用回車在TextBox之間向下移動)_第1張圖片

界面代碼:

View Code
        
           1
        
        
          <
        
        
          body
        
        
          >
        
        
2 < form id ="form1" runat ="server" >
3 < div align ="center" >
4 < fieldset style ="width: 400px; height: 200px;" >
5 < table cellpadding ="3" cellspacing ="3" border ="0" >
6 < tr >
7 < td >
8 < asp:Label ID ="lblName" Text ="姓名: " runat ="server" ></ asp:Label >
9 </ td >
10 < td >
11 < asp:TextBox ID ="txtName" Width ="200px" runat ="server" ></ asp:TextBox >
12 </ td >
13 </ tr >
14 < tr >
15 < td >
16 < asp:Label ID ="lblAddress" Text ="地址: " runat ="server" ></ asp:Label >
17 </ td >
18 < td >
19 < asp:TextBox ID ="txtAddress" Width ="200px" runat ="server" ></ asp:TextBox >
20 </ td >
21 </ tr >
22 < tr >
23 < td >
24 < asp:Label ID ="lblContact" Text ="聯系電話: " runat ="server" ></ asp:Label >
25 </ td >
26 < td >
27 < asp:TextBox ID ="txtContact" Width ="200px" runat ="server" ></ asp:TextBox >
28 </ td >
29 </ tr >
30 < tr >
31 < td >
32 < asp:Label ID ="lblEmail" Text ="電子郵箱: " runat ="server" ></ asp:Label >
33 </ td >
34 < td >
35 < asp:TextBox ID ="txtEmail" Width ="200px" runat ="server" ></ asp:TextBox >
36 </ td >
37 </ tr >
38 < tr >
39 < td >
40 </ td >
41 < td >
42 < asp:Button ID ="btnSubmit" Text ="提交" runat ="server" />
43 < asp:Button ID ="btnReset" Text ="重置" runat ="server" />
44 </ td >
45 </ tr >
46 </ table >
47 </ fieldset >
48 </ div >
49 </ form >
50 </ body >

腳本代碼:

      
         1
      
       <head runat="server">
      
2 <title>Recipe2</title>
3 <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
4 <script type="text/javascript">
5 $(document).ready( function () {
6 $("input:text:first").focus(); // TextBox轉換成html控件為<input type="text"/>
7 $("input:text").bind("keydown", function (e) {
8 if (e.which == 13) { // 獲取Enter鍵值
9 e.preventDefault(); // 阻止表單按Enter鍵默認行為,防止按回車鍵提交表單
10 var nextIndex = $("input:text").index( this ) + 1;
11 $("input:text")[nextIndex].focus();
12 }
13 });
14
15 $("#<%=btnReset.ClientID%>").click( function () {
16 $("form")[0].reset();
17 });
18 });
19 </script>
20 </head>



ASP.NET jQuery 食譜2 (表單中使用回車在TextBox之間向下移動)


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 佛冈县| 溧阳市| 沁阳市| 西和县| 云梦县| 子长县| 勐海县| 英超| 元江| 门源| 临邑县| 烟台市| 垣曲县| 盐池县| 多伦县| 宣武区| 凌云县| 丹阳市| 宁城县| 中山市| 阳曲县| 平昌县| 梨树县| 六枝特区| 泗阳县| 宿迁市| 当涂县| 张家界市| 乌拉特前旗| 上蔡县| 东兰县| 大足县| 科技| 莆田市| 邳州市| 扎赉特旗| 九龙县| 富宁县| 合水县| 浦北县| 山东省|