Vidyalelo
JavaScript · Q48

Document Object Model And Event Handling

Programming · JavaScript · question 48

Q48

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

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

Answer: Option B

Solution

Answer: Option B
Solution:
To select HTML elements based on the value of their name attributes, you can use the getElementsByName() method of the Document object:
var radiobuttons = document.getElementsByName("favorite_color");