您需要更改代碼的一部分,你Ç 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