您需要更改代码的一部分,你Ç opied这样:
$('.form').on('keyup', '.accepted', function(e) {
if (e.which == 13) {
var line = $(this).parent(); // this targets '.line'
//this targets line's "container", which is '.copy', then find all the .current's in the next node (.line)
var current = $(line).parent().next().find('.current');
//as var current returns a list with all the .current's found, even if there's only one, it returns an array of elements in case there were more, so we select the first one from the array
current = $(current)[0];
$(current).focus();
}
});
说明: 作为.accepted是文件装载后创建一个类,它不存在,当你绑定KEYUP功能
您需要使用上()来代替,目标'.accepted',
我已经分解了如何找到'.current'你想让你理解它,但你可以通过几种方式实际达到它。我使用了一个我认为会更容易理解的链接,下面是链接到工作小提琴:http://jsfiddle.net/QaHB3/1/
您显示的代码有什么问题? –
它不起作用:( – Jimmy
.current是一个类名,并且该类有多个字段,如果你想关注一个特定的字段,你可能会给该字段一个唯一的ID并通过id $('# ())。焦点() – daghan