搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
JavaScript
jQuery 教程
jQuery 基础教程
源代码
清空
点击运行
<!DOCTYPE html> <html> <title>动态改变背景颜色示例 - 基础教程(div.cn)</title> <head> <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $(".demo").css("background-color", "yellow"); }); }); </script> </head> <body> <h2 class="demo"> jQuery .class选择器</h2> <p>这是第一段。</p> <p class="demo">这是第二段。</p> <p class="demo">这是第三段。</p> <button type="button">点击我</button> </body> </html>
运行结果