DEV Community

loading...

Discussion on: Getting DOM Elements using JavaScript

Collapse
kevinhch profile image
Kevin

Another way:
const inputs = [...document.getElementById('signup').getElementsByTagName('input')];
// iterate over HTMLCollection
inputs.forEach(element => {
console.log(element);
});

Collapse
attacomsian profile image
Atta Author

Spread operator is very useful. Thank you for the tip 🙌