Document. getelementsbyname () obtains the control object based on the control name. Because the control name can be the same, an array of objects is returned.
Document. getelementbyid () is used to obtain the control object based on the control ID. Because the Control ID is unique, an object is returned.
Document. getelementsbytagname () is used to obtain the control object based on the control tag, and an array of objects is returned.
For example:
Controls in HTML are as follows:
<Input type = "radio" id = "radio1" Checked = "checked" name = "radiogroup1" value = "1"/>
<Input type = "radio" id = "Radio2" name = "radiogroup1" value = "2"/>
<Input type = "radio" id = "radio3" name = "radiogroup1" value = "3"/>
Then:
Document. getelementsbyname ('radiogroup1') gets the three controls. You can use document. getelementsbyname ('radiogroup1') [0] to get the first one.
Document. getelementbyid ('radio1') gets the first control,
Document. getelementsbytagname ('input') gets the three controls,
You can use document. getelementsbytagname ('input') [0] to obtain the first control.
Getelementsbyname ('delid') returns an array composed of all controls named 'delid'. An array is a collection.