<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" href="css/style.css" /> <script src="js/jquery-1.8.3.js"></script> <script> $(function(){ $("#btn1").click(function(){ $("#one").css("background","pink"); }); $("#btn2").click(function(){ $(".mini").css("background","pink"); }); $("#btn3").click(function(){ $("div").css("background","pink"); }); $("#btn4").click(function(){ $("*").css("background","pink"); }); $("#btn5").click(function(){ $("#two .mini").css("background","pink"); }); }); </script> </head> <body> <input type="button" id="btn1" value="选择id为one的元素"/> <input type="button" id="btn2" value="选择样式值为mini的元素"/> <input type="button" id="btn3" value="选择所有的duv元素"/> <input type="button" id="btn4" value="选择所有元素" /> <input type="butto" id="btn5" value="选择id为two并且样式为mini的元素"/> <div id="one"> <div class="mini"> 1111111111 </div> </div> <div id="two"> <div class="mini"> 222222222 </div> <div class="mini"> 3333333 </div> </div> <div id="three"> <div class="mini"> 44444444 </div> <div class="mini"> 5555555 </div> <div class="mini"> 6666666 </div> </div> <span id="four"></span> </body> </html>