Open nicoleJT914 opened 7 years ago
// 创建文档片段,但其不是DOM树的一部分。子元素插入到文档片段中不会引起页面reflow。
// DocumentFragment节点本身不能被插入当前文档。一旦DocumentFragment节点被添加进当前文档,它自身就变成了空节点,可以被再次使用。
document.createDocumentFragment()
document.createElement()
操作DOM
document.getElementById()
docuemnt.querySelector()
// 返回HTMLCollection
document.getElementsByClassName()
document.getElementsByTagName()
// 返回NodeLists
document.querySelectorAll()
// 继承自 HTMLDocument 接口的方法
document.getElementsByName()
// 当前文档是否获得焦点
document.hasFocus()
1.NodeList和HTMLCollection的相同点:
tyoeof NodeList // "function"
tyoeof HTMLCollection // "function"
2.NodeList和HTMLCollection的区别:
Node.childNodes
,返回实时集合;对于document.querySelectorAll()
,返回静态集合!!// NodeList
nodeItem = NodeList[item]
// HTMLCollection
var img = imgs[1] //数字索引
var elem = forms['myFrom'] //ID索引
var item = radio['sex'] //name索引
Document的属性
Document接口是ParentNode接口的扩展
HTML文档的 Document 接口继承自 HTMLDocument 接口