码迷,mamicode.com
首页 > Web开发 > 详细

习惯了CS回车操作人员,操作BS网页表单也是回车666

时间:2017-07-20 20:16:37      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:tde   save   inpu   pre   选中   需要   ror   key   表单   

1.第一步把表单,里面需要回车的input,或者是其他的表单按钮给一个clsss,例如下面的$(‘.cls‘);

2.第二步,  把下面的代码复制过去,填写完最后一个自动提交:$("#savedown").click();

3.选中input的框的时候一定要全部选中,不然操作会不方便,给一个提示

----------------------------------------------------------------------------------------------------------------------------------------

$("input").focus(function() {
                        this.select();
                    });   

-----------------------------------------------------------------------------------------------------------------------------------------

<input style="width:208px;" id="onlyshipid" class="form-control cls" type="text" onblur="clearorchangeNum()">

<input style="width:208px;" id="onlyshipid" class="form-control cls" type="text" onblur="clearorchangeNum()">

$(function(){
                    $("input").focus(function() {
                        this.select();
                    });    
                    $(‘#goodsnameid‘).focus();
                    var $inp = $(‘.cls‘);
                    $inp.bind(‘keydown‘, function (e) {
                    var key = e.which;
                    if (key == 13) {
                        e.preventDefault();
                        var nxtIdx = $inp.index(this) + 1;                
                        if($(‘.cls‘).size() == nxtIdx){
                            $("#savedown").click();
                            $(".cls:eq(" + 0 + ")").focus();
                            $(".cls:eq(" + 0 + ")").select();
                        }else{                        
                            $(".cls:eq(" + nxtIdx + ")").focus();
                            $(".cls:eq(" + nxtIdx + ")").select();
                            
                        }
                    }  
                });
        });   

 

习惯了CS回车操作人员,操作BS网页表单也是回车666

标签:tde   save   inpu   pre   选中   需要   ror   key   表单   

原文地址:http://www.cnblogs.com/historylyt/p/7214201.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!