I am having a form with lots of entries. I would like to change my focus to the next textbox, once I entered the value in the current textbox. and want to continue this proc
In the first question, you don't need an event listener on every input that would be wasteful.
Instead, listen for the enter key and to find the currently focused element use document.activeElement
window.onkeypress = function(e) {
if (e.which == 13) {
e.preventDefault();
var nextInput = inputs.get(inputs.index(document.activeElement) + 1);
if (nextInput) {
nextInput.focus();
}
}
};
One event listener is better than many, especially on low power / mobile browsers.