I ran into another problem with JS created inputs. I want the input to focus on the next one as soon, as it gets filled. So I write a number -> boom I'm on another input. I found this code, already posted on StackOverflow:
var inputs = $(':input').keypress(function(e){
if (e.which == 13) {
e.preventDefault();
var nextInput = inputs.get(inputs.index(this) + 1);
if (nextInput) {
nextInput.focus();
}
}
});
Which I edited to:
var inputs = $(':input').keypress(function(e){
var nextInput = inputs.get(inputs.index(this) + 1);
if (nextInput) {
nextInput.focus();
}
});
It works fine. Until I ad new inputs with JS createElement() function. Then it always stops on the last input that was on the page right after load.
Any solutions? You can follow my work here.
Thanks!