DOM
// 如何获取DOM元素
var app = document.getElementsByTagName("div");
// app HTMLCollection(HTML的集合),不是数组 类数组对象,可以使用数组的属性,可以for循环
console.log(Array.isArray(app))
console.log(app.length)
for(var i=0;i<app.length;i++){
console.log(app[i])
}
getElementsByClassName
<!-- div.one*4{hello $} -->
<div class="one">hello 1</div>
<div class="one">hello 2</div>
<div class="one">hello 3</div>
<div class="one">hello 4</div>
<script>
var all = document.getElementsByClassName("one");
console.log(all);
</script>
getElementById
<div id="app">
app
<div class="one">one1</div>
<div class="one">one1</div>
<div class="one">one1</div>
</div>
<script>
var app = document.getElementById("app");
console.log(app);
// NodeList
var all = document.querySelectorAll(".one");
console.log(all)
</script>