日期:2014-05-17 浏览次数:20631 次
<html> <head> <title></title> </head> <body> <div> <p>test1</p> <p>test2</p> <span>hello world</span> <pre> 浏览器支持程度: * Firefox 3.5: 99.3% * Safari 4: 99.3% * Chrome 2: 99.3% * Opera 10b1: 97.5% * IE 8: 47.4% </pre> </div> </body> </html> <script> if(document.querySelectorAll&&document.querySelector){ var arr=document.querySelectorAll("div p"); for(i in arr){ alert(arr[i].innerHTML); } var span=document.querySelector("div>span"); alert(span.innerHTML); }else{ alert('浏览器不支持'); } </script>