How to select an element by some type attribute (type, for, value) as done in jQuery ex: [type = text]?
I wanted to do a function to skip fields in an automatic form ... I wanted to do type like this, get the tabindex of the current element and make the tabindex + 1 element gain focus ().
Follow the script to skip fields when filled in with the help of Sergio:
function pulacampo(id){
var campo = document.getElementById(id);
var proximo = campo.tabIndex + 1;
var proximoElemento = document.querySelector("[tabindex='" + proximo + "']");
if (campo.value.length == campo.maxLength){
proximoElemento.focus();
}
}
You just need to set the tabindex of the fields and insert the function in keypress / down / up