我有很多像这样的输入字段的表单,
我正在尝试循环具有名称 distanceSlabCost 的元素
$(":text[name^=distanceSlabCost]").each(function(i){
var curTxtBox = $(this);
var nextTxtBox = // find the next text field (?)
var nextTxtFieldId // find the id of next text field (?)
});
如何获取那里的下一个 textField 元素的 id? 此外,如果下一个字段的值为空,则将焦点设置到该字段。
最佳答案
只是一个想法,也许可以使用 class=.distance_slab 遍历容器 div,并使用 next() 获取以下容器 div 及其子元素 (children())。
关于javascript - 查找下一个输入字段并在它为空时设置焦点-jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7306721/