W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>Finding HTML Elements by Query Selector</h1> <p class="intro">Hello World!</p> <p class="intro">Hello China!</p> <p class="intro">Hello Shanghai!</p> <p id="demo"></p> <script> var myElements = document.querySelectorAll("p.intro"); document.getElementById("demo").innerHTML = "类名为 intro 的第三段文本是:" + myElements[0].innerHTML; </script> </body> </html>