Ignore reading the first input

2

How do I ignore the reading of the first value of an array? I do not want to remove the same, just want to display, do not appear the same:

I've already done this:

document.querySelectorAll('.form .form-control').forEach(function (a) {
   console.log(a.value);
});
<form class="form">
    <input type="hidden" class="form-control" value="Não é pra aparecer">
    <input type="text" class="form-control" value="Teste1">
    <input type="text" class="form-control" value="Teste2">
    <input type="text" class="form-control" value="Teste3">
</form>

The first input as you can see, it's just an input of the hidden type and I do not want the value to appear, but I do not want it to be removed either ... Does anyone give me a light?

Thank you!

    
asked by anonymous 02.07.2018 / 13:29

2 answers

1

You can get the class form-control from <input type="hidden" class="form-control" value="Não é pra aparecer"> , so it will not be called by:

document.querySelectorAll('.form .form-control').forEach(function (a) {
   console.log(a.value);
});
    
02.07.2018 / 14:14
2

If you want to ignore the element because it is "hidden", just do this in the selector, with :not([type="hidden"]) .

Or if you want to ignore the first one, switch to a command for by ignoring the first element.

See the two examples below:

console.log("ignorando hidden");
document.querySelectorAll('.form .form-control:not([type="hidden"]').forEach(function (a) {
   console.log(a.value);
});


console.log("ignorando primeiro elemento");
var elementos = document.querySelectorAll('.form .form-control');
for(var x=1; x<elementos.length;x++) {
  console.log(elementos[x].value);
}
<form class="form">
    <input type="hidden" class="form-control" value="Não é pra aparecer">
    <input type="text" class="form-control" value="Teste1">
    <input type="text" class="form-control" value="Teste2">
    <input type="text" class="form-control" value="Teste3">
</form>
    
02.07.2018 / 13:51