标签:
html:
<h1>找对象</h1> <div id="div1"> <p>p1</p> <p>p2</p> <p>p3</p> </div> <div class="div2"></div> <input type="text" name="username">
js:
①
console.log(document.getElementById("div1"));
输出:
<div id="div1"> <p>p1</p> <p>p2</p> <p>p3</p> </div>
类型是 [object HTMLDivElement]
②
console.log(document.getElementsByTagName("p"));
输出:
[p, p, p, item: function, namedItem: function] 0: p 1: p 2: p length: 3 __proto__: HTMLCollection
类型是 [object HTMLCollection]
标签:
原文地址:http://www.cnblogs.com/dee0912/p/4457706.html