- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当文本框值长度达到最大值时,我希望它移动到下一个选项卡,或者 3 秒后它移动到下一个选项卡。这是我的代码:
$(".tab").keyup(function () {
var get = $(this);
if (get.val().length == this.maxLength) {
get.next('tr .tab').focus();
}
else {
setTimeout(function () {
get.next('tr .tab').focus();
}, 3000);
}
});
当光标位置在1时,移动2。但当光标在2时,不移动3。 HTML 代码如下:
<table cellspacing="0" cellpadding="0">
<tr>
<td class="tds">Year / Number</td>
<td><input name="year" type="text" class="inputbox tab" maxlength="4" style="width:25px;" /> / <input name="number" type="text" class="inputbox tab" maxlength="2" style="width:25px;"/></td>
</tr>
<tr>
<td class="tds">Caption:</td>
<td><input name="caption" type="text" class="inputbox tab" style="width:500px;" /></td>
</tr>
<tr>
<td class="tds">Description:</td>
<td><input name="desc" type="text" class="inputbox tab" style="width:500px;" /></td>
</tr>
</table>
如果光标在 1 到 2 范围内,如果光标在 2 到 3 范围内,后来在 3 到 4 范围内,我如何管理焦点?
最佳答案
<强> LIVE DEMO
var timeo, // Used for our timeout
$TAB = $('.tab'); // Cache all your input elements for reuse
$TAB.keyup(function () {
clearTimeout(timeo); // Clear timeout as you type
var $el = $(this), // cache element
val = this.value, // get value
len = this.maxLength, // get length
i = $TAB.index( this ); // get the index of current one
// so we can increase it using +1
if (len != -1 && val.length >= len) {
$TAB.eq(i+1).focus();
}
timeo = setTimeout(function () {
$TAB.eq(i+1).focus();
}, 3000);
});
我会尝试根据您的问题解释我的更改:
您的input
元素并不都在同一个 <TD>
内父级,因此您不能使用 .next()
得到......好吧......“不是下一个”。
将所有输入缓存在 $TAB
中多变的。现在在keyup
里面我们需要跟踪index
当前使用的输入的值,而不是增加 i = $TAB.index( this );
的值你可以得到下一个索引 input
从我们的元素集合中$TAB
即:
$TAB.eq(i+1) // is the next one in collection
您没有清除您的setTimeout
正确地,因此它会在不等我们完成输入的情况下滴答作响。我在这种情况下使用了 timeo
变量来存储 timeout
而且还允许我们在字段中输入时清除它。
还有,if (len != -1
将确保元素具有 maxlength
属性和 && val.length >= len) {
将检查输入的值是否大于允许的最大长度。
关于jquery autotab 不要制表符下一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21865347/
使用制表符 - 最初,当我构建表时,我可以在列定义中提供验证选项: {title:"Rating", field:"rating", editor:"input", validator:"requir
在 Notepad++ 中有一个非常方便的按钮,我可以按下它来查看空格、制表符和换行符所在的符号,这样我就可以看到哪些空格是由空格引起的,哪些是由制表符引起的。我可以在 emacs 中做到这一点吗?如
我在 .NET Windows 窗体应用程序中使用 RichTextBox 控件。我允许用户在文本框本身内按 TAB 键。但是,当我将 .Text 值保存在文本框中时,它将显示如下: "This[]i
我想知道如何使用 Interactive Demo 上使用的选择器来清除过滤器对于性别标题。 最佳答案 如果您询问如何向选择 header 过滤器添加空选项,则只需在 headerFilterPara
我有一个包含搜索结果的制表器。这是代码: var table = new Tabulator("#json-table", { layout:"fitDataFill", //init
我正在尝试构建一个可由用户修改的交互式表格。就我而言,原始数据集是本地对象数组。 制表符具有用于删除行的buttonCross选项,但它仅影响表格视觉效果。如何让它找到该行呈现的匹配对象并将其从表数据
我正在制作许多原始 html 表格并使用它们将它们转换为制表符 var table = new Tabulator("#main", { layout:"fitColumns", to
这个问题在这里已经有了答案: Any way for a combo box with 2 values per line? (3 个答案) 关闭 9 年前。 我有一个包含各种项目的 CSV 文件。
我是 JavaScript 的新手,目前正在学习如何使用 Tabulator(除此问题外它工作得很好)。 我想为每个列标题添加一个菜单按钮,然后打开一个下拉菜单。从此菜单中,用户应该能够选择“Grou
我正在尝试处理文本区域中的粘贴代码,并希望对粘贴到第一个非间距字符的内容进行左 trim 。我想采用以下代码: if (foo) { console.log(bar);
我预计 TAB 字符会比 SPACE 字符宽,但在 HTML5 canvas 中,它们是相同的。加上其他一些,这不是那么重要: var c=document.getElementById('mycan
在 shell(GNU bash,版本 4.2.47(1)-release (x86_64-suse-linux-gnu))中,当我点击自动完成选项卡时,“$”在之后被转义变量名称已完成,但如果没有完
我正在制作一个程序,我将从 mysql 表中的 txt 文件加载数据。我将创建具有特定字段的表,然后我将从其中的 txt 文件加载数据。我正在使用 java 来执行该程序。 我写的是下面的内容: pr
Tabulator 有一个名为Column Calculations 的模块。 我需要添加页面总和和总和 例如,我可以添加页脚来计算总和,但我无法添加可见行总和,或者换句话说当前页面的总和仅在同一时间
我不是 javascript 专家,所以我有一个简短的问题,有人知道如何在这里使用 JavaScript tabifier - http://www.barelyfitz.com/projects/t
这是我之前问题的延续(如果你好奇,请检查它们)。 我已经看到了隧道尽头的曙光,但还有最后一个问题。 出于某种原因,每一行都以制表符开头。 我怎样才能忽略第一个字符(在我的例子中是“制表符”(\t))?
请指教以下理解问题??? 我在我的 Linux 机器上输入:(以便通过 top 命令获取总内存) top -n1 | grep Mem: Mem: 2075024k total, 2059064
我该如何解决这个问题: 原因: java.lang.IllegalArgumentException: String [\t] with length 2 cannot be co
1.用法 \t 表示制表符,相当于制表符 前面的输出内容位数为8的倍数,\t将输出8个空格 前面的输出内容位数不是8的倍数,\t将补足8位 2.测试用例 少于8位 等于8位 大于8位
我正在尝试将 Tabulator v4.6.3 与 fitData 布局一起使用。这是我的代码: var table = new Tabulator("#cowTable", { da
我是一名优秀的程序员,十分优秀!