I have 6 inputs in a form, each with a class of .first .second .third .fourth .fifth .sixth respectively and I'd like to select them with vanilla JS but after trying with getElementsByClassName and querySelectorAll, it still didn't work out.
here is my line of code:
document.querySelectorAll("form input")[0].value==""
How do I select all the elements with those classes?
Thanks in advance for any help rendered!
Your current code
document.querySelectorAll("form input")
is basically getting what you want. However, you then do[0].value==""
which is basically getting the first input and checking if it's value is empty. You could apply the classsand
to all the inputs doing something like:You an simply select by tag name:
https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName