0

In Plain Ole' Javascript, do I NEED to use a loop to loop through the radio buttons/checkboxes to see if they are checked or is there a simpler way of doing this?

1 Answer 1

3

Yes. It may be most helpful to...

  • ...have them all contained in one element, so you can traverse through its children
  • ...apply a class name to all of them, to use document.getElementsByClassName
  • ...use document.getElementsByTagName (though, the tag is the input tag, so you may get other elements as well)

However, that is just getting the elements; but as you've stated, you will still need to iterate through each one to do whatever comparison you like. jQuery will allow you to do this kind of thing more easily, but "Plain Ole' Javascript" cannot.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.