HTML
CSS
JavaScript
Vue
React
Python
PHP
Java
.Net
Java9手册
PHP手册
CSS3手册
jQuery手册
源代码
在线运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(cainiaoplay.com)</title> </head> <body> <h2 class="example">使用 class="example" 的标题</h2> <p class="example">使用 class="example" 的段落</p> <p class="example">另外一个使用 class="example" 的段落</p> <p>点击按钮为第一个 class="example" (索引为 0) 的 p 元素设置背景颜色。</p> <button onclick="myFunction()">点我</button> <p><strong>注意:</strong>Internet Explorer 8 及更早版本不支持 querySelectorAll() 方法。</p> <script> function myFunction() { var x = document.querySelectorAll("p.example"); x[0].style.backgroundColor = "red"; } </script> </body> </html>
动行结果