easyui中方向键、tab键、回车键

来源:互联网 发布:顶点软件牛叉诊股 编辑:程序博客网 时间:2024/05/18 18:01

1.html中

复制代码
        function changeTab(event, i) {            var keyCode = event.keyCode;            var inputs = jQuery("#table :input"); // 获取表单中的所有输入框            var idx = inputs.index(i);            if (inputs.length < 4) {                return false;            }            if(idx >= inputs.length - 3){                switch (keyCode) {                    case 38:        //                        inputs[idx - 3].focus(); // 设置焦点                        inputs[idx - 3].select(); // 选中                        break;                    default:                        break;                }            }else if(idx < 3){                switch (keyCode) {                    case 13:     //回车键                        inputs[idx + 3].focus(); // 设置焦点                        inputs[idx + 3].select(); // 选中                        break;                    case 40:        //                        inputs[idx + 3].focus(); // 设置焦点                        inputs[idx + 3].select(); // 选中                        break;                    default:                        break;                }            }else{                switch (keyCode) {                    case 13:      //回车键                        inputs[idx + 3].focus(); // 设置焦点                        inputs[idx + 3].select(); // 选中                        break;                    case 37:        //                        inputs[idx - 1].focus(); // 设置焦点                        inputs[idx - 1].select(); // 选中                        break;                    case 38:        //                        inputs[idx - 3].focus(); // 设置焦点                        inputs[idx - 3].select(); // 选中                        break;                    case 39:        //                        inputs[idx +1].focus(); // 设置焦点                        inputs[idx +1].select(); // 选中                        break;                    case 40:        //                        inputs[idx + 3].focus(); // 设置焦点                        inputs[idx + 3].select(); // 选中                        break;                    default:                        break;                }            }            return true;        }
0 0