1. 程式人生 > >獲取元素節點的方法比較

獲取元素節點的方法比較

獲取dom節點

原生方法:
document.getElementByID()
document.getElementsByClassName()
document.getElementsByTagName()
H5 擴張DOM方法:
document.querySelector()
document.querySelectorAll()

區別:
1.用法 後者 類似JQuery $ css選擇器用法
2.兼容性 後者IE8+
3.性能 get>query>$
4.動態與靜態 前者是動態選擇器 後者是靜態選擇器

獲取元素節點的方法比較