方法1: 使用document.getElementById();
方法2: 使用document.querySelector();
document.getElementById("app");
document.querySelector("#app");
注意:
1. 方法1比方法2的效率高很多, 建議使用方法1;
2. 兩個方法都是直接返回目標元素節點, 而非節點集合對象;
3. getElementById()方法只能作用在document對象上;
方法1: 使用document.getElementById();
方法2: 使用document.querySelector();
document.getElementById("app");
document.querySelector("#app");
注意:
1. 方法1比方法2的效率高很多, 建議使用方法1;
2. 兩個方法都是直接返回目標元素節點, 而非節點集合對象;
3. getElementById()方法只能作用在document對象上;
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。