The Wayback Machine - https://web.archive.org/web/20150906071614/https://developer.mozilla.org/zh-CN/docs/Web/API/CharacterData

CharacterData

1 位贡献者:

这篇翻译不完整。请帮忙从英语翻译这篇文章

CharacterData 抽象接口(abstract interface)代表 Node 对象包含的字符。这是一个抽象接口,意味着没有 CharacterData 类型的对象。 它是在其他接口中被实现的,如 TextCommentProcessingInstruction 这些非抽象接口。

属性

从其父级 Node 继承属性,并且实现了 ChildNodeNonDocumentTypeChildNode 接口。

CharacterData.data
一个 DOMString,表示该对象中包含的文本数据。
CharacterData.length 只读
返回一个 unsigned long 的表示 CharacterData.data 包含的字符串的大小。
NonDocumentTypeChildNode.nextElementSibling 只读
返回其父节点所在的子节点列表(children list)中紧跟着的元素节点 Element,或者 null
NonDocumentTypeChildNode.previousElementSibling 只读
返回其父节点所在的子节点列表(children list)中前一个元素节点 Element,或者 null

方法

Inherits methods from its parent, Node, and implements the ChildNode and NonDocumentTypeChildNode interface.

CharacterData.appendData()
Appends the given DOMString to the CharacterData.data string; when this method returns, data contains the concatenated DOMString.
CharacterData.deleteData()
Removes the specified amount of characters, starting at the specified offset, from the CharacterData.data string; when this method returns, data contains the shortened DOMString.
CharacterData.insertData()
Inserts the specified characters, at the specified offset, in the CharacterData.data string; when this method returns, data contains the modified DOMString.
ChildNode.remove()
Removes the object from its parent children list.
CharacterData.replaceData()
Replaces the specified amount of characters, starting at the specified offset, with the specified DOMString; when this method returns, data contains the modified DOMString.
CharacterData.substringData()
Returns a DOMString containing the part of CharacterData.data of the specified length and starting at the specified offset.

规范

Specification Status Comment
DOM
CharacterData
Living Standard Added implemention of the ChildNode and NonDocumentTypeChildNode interface.
Document Object Model (DOM) Level 3 Core Specification
CharacterData
Recommendation No change from Document Object Model (DOM) Level 2 Core Specification.
Document Object Model (DOM) Level 2 Core Specification
CharacterData
Recommendation No change from Document Object Model (DOM) Level 1 Specification.
Document Object Model (DOM) Level 1 Specification
CharacterData
Recommendation Initial definition.

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 1.0 (1.7 or earlier) 6 (Yes) (Yes)
Implements ChildNode interface. ? 25.0 (25.0) [1] 未实现 ? 未实现
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) 1.0 (1.0) (Yes) (Yes) (Yes)
Implements ChildNode interface. ? 25.0 (25.0) [1] 未实现 ? 未实现

[1] Two properties, nextElementSibling and previousElementSibling, have been moved to the NonDocumentTypeChildNode interface, also implemented by CharacterData.

相关链接

文档标签和贡献者

向此页面作出贡献: AlexChao
最后编辑者: AlexChao,