Which of the following can be used to select HTML elements based on the value of their name attributes?

A getElementByName()
B getElementsByName()
C getElementsName()
D getElementName()

Correct Answer: getElementsByName()

The getElementsByName() method returns a collection of all elements in the document with the specified name (the value of the name attribute), as a NodeList object. var radiobuttons = document.getElementsByName("favorite_color");

Related Questions

What is the reason for avoiding the attributes property in the HTML DOM?

Next steps