querySelectorAll 方法相比 getElementsBy 系列方法有什么区别?
1.规范不同
querySelectorAll是Selector API中的规范
而getElementsBy系列是DOM系列
2.接受参数不同
querySelectorAll 方法接受的是css选择符
3.一个是静态的一个是动态的。
queryslectorAll是一个静态的nodelist的集合,是集合的一个快照,对文档的任何操作都不会对其产生影响。
getElementByTagName是一个动态的HTMLcolection的集合,每次调用都会重新对文档进行查询
4.NodeList与HTMLColection的区别
NodeList 对象会包含文档中的所有节点,如 Element、Text 和 Comment 等。
HTMLCollection 对象只会包含文档中的 Element 节点。
getElementsByTagName
getElementsByClassName
getElementsByName
getElementsById