代码:
<script> var v1=document.getElementById('my1'); console.log(v1); var v2=document.getElementsByTagName("h2"); console.log(v2); for (var i=0;i<v2.length;i++){ console.log(v2[i]); } var v3=document.querySelector("#my1"); console.log(v3); var v4=document.querySelectorAll('h1'); console.log(v4[0]); console.log(v4[1]); </script>
后