代码案例:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <button>快速</button> <button>快速</button> <button>快速</button> <button>快速</button> <button>快速</button> <button>快速</button> <button>快速</button> <script src="../JQuery2/jquery-3.6.0.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> $(function(){ //1.隐式迭代 给所有的按钮都绑定了点击事件 $("button").click(function(){ //2.当前的元素变化背景颜色 $(this).css("background","pink") //3.其余的兄弟去掉背景颜色 隐式迭代 $(this).siblings("button").css("background","") }) }) </script> </body> </html>