W3C DOM 支持哪些方法?


以下是 W3C DOM 支持的方法:

序号
属性及描述
1
createAttribute(name)
返回一个新创建的,带有指定名称的 Attr 节点。
例:document.createAttribute(name)
2
createComment(text)
创建并返回一个包含指定文本的新 Comment 节点。
例:document.createComment(text)
3
createDocumentFragment()
创建并返回一个空的 DocumentFragment 节点。
例:document.createDocumentFragment()
4
createElement(tagName)
创建并返回一个带有指定标签名称的新 Element 节点。
例:document.createElement(tagName)
5
createTextNode(text)
创建并返回一个包含指定文本的新 Text 节点。
例:document.createTextNode(text)
6
getElementById(id)
返回此文档中其 id 属性具有指定值的 Element,如果文档中不存在这样的 Element,则返回 null。
例:document.getElementById(id)
7
getElementsByName(name)
返回文档中所有其 name 属性具有指定值的元素的节点数组。如果没有找到这样的元素,则返回一个零长度数组。
例:document.getElementsByName(name)
8
getElementsByTagName(tagName)
返回此文档中所有具有指定标签名称的 Element 节点的数组。Element 节点在返回的数组中出现的顺序与其在文档源中出现的顺序相同。
例:document.getElementsByTagName(tagName)


更新于:2020年6月23日

83 次浏览

启动您的职业生涯

完成课程获得认证

开始学习
广告