W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h2>This is a h2 element</h2> <p>This is a p element</p> <p>This is also a p element.</p> <p>This is also a p element - 单击按钮可更改此文档中所有 p 元素的背景颜色。</p> <button onclick="myFunction()">试一试</button> <script> function myFunction() { var myNodelist = document.getElementsByTagName("P"); var i; for (i = 0; i < myNodelist.length; i++) { myNodelist[i].style.backgroundColor = "red"; } } </script> </body> </html>