Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js loop through form inputs

const form = document.querySelector('form');

// A)
Array.from(form.elements).forEach(el => console.log( el ));

// B)
[...form.elements].forEach(el => console.log( el ));

// C)
for (const el of form.elements) {
  console.log( el );
}
 
PREVIOUS NEXT
Tagged: #js #loop #form #inputs
ADD COMMENT
Topic
Name
4+3 =