DOM/domcore/Document
Document
The Document interface represents the entire HTML or XML document. Conceptually, it is the root of the document tree, and provides the primary access to the document's data.
Attributes
| Name | Description |
|---|---|
implementation | Returns the DOM implementation associated with this document. |
compatMode | Indicates whether the document is rendered in Quirks or Strict mode. |
doctype | Returns the Document Type Declaration associated with this document. |
documentElement | Allows direct access to the child node that is the document element of the document. |
Methods
| Name | Description |
|---|---|
getElementsByTagName(localName) | Returns a list of all the Elements in document order with a given local name(tag name). |
getElementsByTagNameNS(namespace, localName) | Returns a list of all the Elements with a given local name and namespace URI in document order. |
getElementsByClassName(classNames) | Returns the Element that has an class attribute with the given value. |
getElementById(elementId) | Returns the Element that has an ID attribute with the given value. |
createElement(localName) | Creates an element of the type specified. |
createElementNS(namespace, qualifiedName) | Creates an element of the given qualified name and namespace URI. |
createDocumentFragment() | Creates an empty DocumentFragment object. |
createTextNode(data) | Creates a Text node given the specified string. |
createComment(data) | Creates a Comment node given the specified string. |
createProcessingInstruction(target, data) | Creates a ProcessingInstruction node given the specified name and data strings. |
importNode(node, deep) | Imports a node from another document to this document |
adoptNode(node) | Attempts to adopt a node from another document to this document. |
本文详细介绍了HTML和XML文档的Document对象,它是文档树的根节点,提供了主要的数据访问途径。文章列举了Document对象的主要属性和方法,包括获取元素、创建节点等关键操作。
130

被折叠的 条评论
为什么被折叠?



