Document Object

Definition and Usage

The Document object is the root of a document tree.

The Document object gives us access to the document's data.

Since element nodes, text nodes, attributes, comments, etc. cannot exist outside the document, the Document object contains methods to create these objects. All Node objects have a ownerDocument property which associates them with the Document where they were created.

Note: The Document object can also use the properties and methods of the Node object.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The Document object is supported in all major browsers.


Document Object Properties

The "DOM" column indicates in which DOM Level the property was introduced.

Property Description DOM
doctype Returns the Document Type Declaration associated with the document 1
documentElement Returns the Document Element of the document (the HTML element) 1
documentURI Sets or returns the location of the document 3
domConfig Returns the configuration used when normalizeDocument() is invoked 3
implementation Returns the DOMImplementation object that handles this document 1
inputEncoding Returns the encoding, character set, used for the document 3
strictErrorChecking Sets or returns whether error-checking is enforced or not 3
xmlEncoding Returns the XML encoding of the XML document 3
xmlStandalone Sets or returns whether the XML document is standalone or not 3
xmlVersion Sets or returns the XML version of the XML document 3

Document Object Methods

The "DOM" column indicates in which DOM Level the method was introduced.

Method Description DOM
adoptNode(node) Adopts a node from another document to this document. Returns the adopted node 3
createAttribute() Creates an attribute node 1
createAttributeNS(URI,name) Creates an attribute with the specified name and namspaceURI 2
createCDATASection() Creates a CDATA node with the specified text. For XML DOM only 1
createComment() Creates a Comment node with the specified text 1
createDocumentFragment() Creates an empty DocumentFragment node 1
createElement() Creates an Element node 1
createElementNS() Creates an element with the specified namespace 2
createEntityReference() Creates an EntityReference node. For XML DOM only 1
createProcessingInstruction() Creates an EntityReference node. For XML DOM only 1
createTextNode() Creates a Text node 1
getElementById() Returns the element that has the ID attribute with the specified value 2
getElementsByTagName() Returns a NodeList containing all elements with the specified tagname 1
getElementsByTagNameNS() Returns a NodeList containing all elements with the specified namespaceURI and tagname 2
importNode() Imports a node from another document 2
normalizeDocument() Removes empty Text nodes, and joins adjacent nodes 3
renameNode() Renames the specified node 3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值