1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <div id="one"></div> <div class="c1"></div> <h1 class="c1"></h1> <a href="###">哈哈哈哈</a> <div class="box"> <a href="###">京东</a> <a href="###">淘宝</a> </div> </body> </html> <script type="text/javascript"> var divArray=document.querySelectorAll("div"); console.log(divArray); var c1Array=document.querySelectorAll(".c1"); console.log(c1Array); var aArray=document.querySelectorAll(".box a:first-child"); console.log(aArray); var a=document.querySelector(".box a"); console.log(a); var one=document.querySelector("#one"); console.log(one); </script>
|