javascript node element

来源:互联网 发布:浪潮软件利好消息 编辑:程序博客网 时间:2024/06/07 03:31

Node (W3C DOM Core object)

SPECVersionDepr.DOM1NO




Example

<h1 id="greeting">Be excellent to each other</h1>

In the example above, h1 is an Element node, id="greeting" is an Attr node, and the text inside the heading is a Text node.

Description

The Node interface is the primary data type for the Document Object Model (DOM). It represents any single item in the tree, such as an ElementAttrDocument or Entity.

Whether a Node may have children depends on its type.

The following table is an overview of each of the core interfaces, showing how thenodeName and nodeType returns, and what kind of children the node is allowed to have.

Table 1. A summary of universal Node propertiesInterfacenodeNamenodeTypeChildrenElementThe tag name, eg.HTML1ElementTextComment,ProcessingInstruction,CDATASection,EntityReferenceAttrThe attribute name, eg.id2TextEntityReference1Text#text3Cannot have childrenCDATASection#cdata-section4Cannot have childrenEntityReferenceThe name of the entity reference, eg. amp5Element,ProcessingInstruction,CommentText,CDATASection,EntityReferenceEntityThe entity name, eg.&6Element,ProcessingInstruction,CommentText,CDATASection,EntityReferenceProcessingInstructionThe target of the processing instruction, eg. xml-stylesheet7Cannot have childrenComment#comment8Cannot have childrenDocument#document9Element (one only),ProcessingInstruction,CommentDocumentType(one only)DocumentTypeThe name of the document type, eg.html10Cannot have childrenDocumentFragment#document-fragment11Element,ProcessingInstruction,CommentText,CDATASection,EntityReferenceNotationThe notation name12Cannot have children


In this Section


Element (W3C DOM Core object)


SPECVersionDepr.ParentDOM1NONODE




Example

<p>  <q>Don't be too proud of this technological terror you've constructed.  The ability to destroy a planet is <strong>insignificant</strong>  next to the power of The Force.</q></p>

In the example above, the <p><q> and <strong> are all Element nodes.

Description

The Element interface inherits from Node, and represents a single element in an HTML or XML document.

An Element node may have other ElementTextCommentProcessingInstruction,CDATASection or EntityReference nodes as children.

In this Section



0 0
原创粉丝点击