安科网
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>安科教程(www.ancii.com)</title> </head> <body> <h2 class="example">class="example" 的标题</h2> <p class="example">class="example" 的段落。</p> <p>点击按钮为第一个带有 class="example" 的 p 元素添加背景颜色。</p> <button onclick="myFunction()">点我</button> <script> function myFunction() { document.querySelector("p.example").style.backgroundColor = "red"; } </script> </body> </html>
运行结果
Copyright © 2013 - 2019 Ancii.com All Rights Reserved
京ICP备18063983号-5
京公网安备11010802014868号