JavaScript and Dom have many array objects. They have the following features:
1. The Length attribute exists.
2. You can use [] to access through subscript
3. When using [] to access members, you can use not only subscript, but also ID or name.
4. Since the first and second conditions are met, you can also traverse them through the for loop.
However, just like their names, they are just like arrays, rather than arrays, and they cannot use the special methods of arrays, such as slice, push, and pop. However, if you really need them to work like arrays, you can use array. Prototype. Slice (class array object, 0) to generate an array. The generated array also loses the unique method of the original class array object and the access feature of [] Using name
The following is an introduction to some class array objects.
1. Arguments
Arguments is the most common class array object used inside the function. Arguments [0] Or functionname. Arguments [0]
Member Introduction
Attribute length // length callee // the function being executed
Ii. nodelist
BelowCodeThe return type is nodelist.
Childnodes
Labels (select element)
Getelementsbyname (name)
Getelementsbyclassname (classname)
Getelementsbytagname (tagname)
Getelementsbytagnamens (namespaceuri, tagname)
Queryselectorall (selectors) document. All. Tags (tagname)
Member Introduction
Attribute length // length method item (idx) // access member. subscript and element ID are supported.
3. stylesheetlist
The return type is nodelist in the following code.
Document. stylesheets
Member Introduction
Attribute length // length method item (idx) // access member. subscript, element ID, and element name are supported.
Iv. htmlcollection
The following code returns an htmlcollection type.
Children
Document. Images // All IMG Elements
Document. Links // All A and area elements with the href attribute
Document. Anchors // All a elements with name attributes
Document. Forms // All form elements
Document. scripts // All script elements
Document. Applets // All applet Elements
Document. embeds // All embed Elements
Document. plugins // document. Same as embeds
Tbodies (table element)
Rows (table, tbody, thead, tfoot element)
Cells (TR element)
Areas (MAP element)
Member Introduction
Attribute length // length method item (idx) // access Member, supporting subscript, element ID, element namenameditem (name) // access Member, element ID, element name
5. htmlformcontrolscollection (inheriting htmlcollection)
The following code returns the htmlformcontrolscollection type.
Elements (Form element)
Member Introduction
Attribute length // length method item (idx) // access Member, supporting subscript, element ID, element namenameditem (name) // access Member, element ID, element name
6. htmloptionscollection (inheriting htmlcollection)
The following code returns the htmlformcontrolscollection type.
Options (select element)
Member Introduction
Property length // length selectedindex // The subscript method of the currently selected option item (idx) // access Member, supporting subscript, element ID, element namenameditem (name) // access member, support Element ID and nameadd (option, beforeindex) // Add optionremove (INDEX) // delete option
VII. htmlallcollection
The following code returns the htmlformcontrolscollection type.
Document. All
Member Introduction
Attribute length // length method item (idx) // access Member, supporting subscript, element ID, element namenameditem (name) // access Member, element ID, element nametags (tagname) // return the nodeli of the specified tag name
8. domtokenlist
This is a new feature in HTML5. It aims to solve the complicated operation problem when multiple classes are involved in classname setting or deleting classes.
The following code returns the domtokenlist type.
Classlist (element)
Member Introduction
Attribute length // method of length item (INDEX) // access the Member, use subscript add (idx) // Add class remove (classname) // Delete class toggle (classname) // If a class exists, delete it. If no class exists, add contains (classname) // check whether the class exists.