javascript node element

Node (W3C DOM Core object)

SPEC
Version Depr.
DOM1 NO





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 properties
Interface nodeName nodeType Children
Element The tag name, eg.HTML 1 ElementTextComment,ProcessingInstruction,CDATASection,EntityReference
Attr The attribute name, eg.id 2 TextEntityReference1
Text #text 3 Cannot have children
CDATASection #cdata-section 4 Cannot have children
EntityReference The name of the entity reference, eg. amp 5 Element,ProcessingInstruction,CommentText,CDATASection,EntityReference
Entity The entity name, eg.& 6 Element,ProcessingInstruction,CommentText,CDATASection,EntityReference
ProcessingInstruction The target of the processing instruction, eg. xml-stylesheet 7 Cannot have children
Comment #comment 8 Cannot have children
Document #document 9 Element (one only),ProcessingInstruction,CommentDocumentType(one only)
DocumentType The name of the document type, eg.html 10 Cannot have children
DocumentFragment #document-fragment 11 Element,ProcessingInstruction,CommentText,CDATASection,EntityReference
Notation The notation name 12 Cannot have children


In this Section


Element (W3C DOM Core object)


SPEC
Version Depr. Parent
DOM1 NO NODE





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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值