Htmlcollection Interface Definition
Interface Htmlcollection
{
ReadOnly attribute unsigned long length;
Node item (in unsigned long index);
Node Nameditem (in Domstring name);
}
What must be said for the Htmlcollection collection object is the Nameditem method. Look at the explanation of the specification.
Original:
Nameditem method
This method retrieves a node using a name. With [HTML 4.01] documents, it's a node with a matching id attribute. If it doesn ' t find one, it then searches for a node with a matching name attribute, but only on those elements that are AL lowed a name attribute. With [XHTML 1.0] Documents, this method is only searches to nodes with a matching id attribute. This is case insensitive in HTML documents and case sensitive in XHTML documents.
--------------------------------------------------------------------------------
Translation:
Nameditem Method:
This method obtains the node through the ' name ' attribute.
In the html4.01 document, it first searches for the value of the node's ID attribute. If no matching node is found, search for the node with which the Name property matches. That is, under the html4.01 DTD, browsers should take precedence over IDs to get nodes. Second is name.
In the XHTML 1.0 document, only the node that matches the id is searched.
For the value of the node (ID or name) attribute, this method ignores the case difference in the HTML document and is in the XHTML document. The case is different.
The bold part above is very important, and there is no such thing as a guide. Some of the problems that come up later are very difficult to determine. Because many browsers are not implemented the same way.