我的代码应该是:
<input>
- 完成我该如何解决?
for (var i = 0; i < 10; ++i) {
if (i == 0) {
$('#tags').append('<input name="group_interests[]" class="group_interests" type="text" />');
} else {
$('#tags').append('<input name="group_interests[]" class="group_interests default_text" type="text" value="start typing to see the list" />');
}
}
$('#tags .group_interests:gt(2)').hide();
$('#tags .group_interests:visible').last().focus( function() {
$(this).next().show();
});
答案 0 :(得分:1)
您的焦点始终与同一输入绑定。 试试这个:
for (var i = 0; i < 10; ++i) {
if (i == 0) {
$('#tags').append('<input name="group_interests[]" class="group_interests" type="text" />');
} else {
$('#tags').append('<input name="group_interests[]" class="group_interests default_text" type="text" value="start typing to see the list" />');
}
}
$('#tags .group_interests:gt(2)').hide();
$('#tags .group_interests:visible').last().focus(showNext);
function showNext() {
$(this).unbind('focus').next().show().focus(showNext);
}