document.getElementById1, getElementById
Function: The ID in the General page is unique and is used to prepare an element for positioning
Syntax: document.getElementById (ID)
Parameter: ID: Required option is string
return value: Object; Returns the first in the same ID object, in the order in which the page appears, or null if there are no eligible objects
Example
document.getElementById ("Id1"). Value;
2, Getelementsbyname
Function: Finds an array of elements of the same name by the names of the elements
Syntax: Document.getelementsbyname (name)
Parameter: Name: Required option is string
Return value: Array object; If there are no eligible objects, an empty array is returned, in the order in which they appear in the page note: Returns the value of the array value as the Values property, and if a label has no Value property, when you add the Value property and assign a value, Getelementsbyname can also fetch its value. When no value is assigned to the Value property, Getelementsbyname returns the array value undefined, but still gets the number of the same name label Document.getelementsbyname (name). length Document.getelementsbyname can still be used when the Name property is not set, it will take the value of the property based on your ID
Example
Document.getelementsbyname ("name1") [0].value;
Document.getelementsbyname ("name1") [1].value; <span id= ' cbylawindexname ' class= ' normalnode ' value= ' all ' > All </span> ' <span id= ' Cbylawindexname ' class = ' Normalnode ' value= ' all > Full </span> ' span tag does not actually have the name and Value property but Document.getelementsbyname ("Cbylawindexname ") will still get the value
3, getElementsByTagName
Function: Query by HTML tag name, return an array of the same tag element
Syntax: Object.getelementsbytagname (tagname) object can be document or event.srcElement.parentElement, etc.
Parameter: tagname: The required option is a string, which is retrieved according to the HTML tag.
Return value: Array object; If there are no eligible objects, an empty array is returned, in the order in which they appear in the page
Example
document.getElementsByTagName ("P") [0].childnodes[0].nodevalue;
document.getElementsByTagName ("P") [1].childnodes[0].nodevalue
Document.getelementbyid/name/tagname