使用的方法:click()    css()   siblings()   

 1     <button>快速</button>
 2     <button>快速</button>
 3     <button>快速</button>
 4     <button>快速</button>
 5     <button>快速</button>
 6     <button>快速</button>
 7     <button>快速</button>
 8     <script>
 9         $(function() {
10             // 1. 隐式迭代 给所有的按钮都绑定了点击事件
11             $("button").click(function() {
12                 // 2. 当前的元素变化背景颜色
13                 $(this).css("background", "pink");
14                 // 3. 其余的兄弟去掉背景颜色 隐式迭代
15                 $(this).siblings("button").css("background", "");
16             });
17         })
18     </script>

 

相关文章:

  • 2021-07-27
  • 2022-01-05
  • 2022-12-23
  • 2021-10-09
猜你喜欢
  • 2021-11-13
  • 2022-12-23
  • 2021-10-23
  • 2021-12-03
  • 2022-12-23
  • 2021-08-23
  • 2022-12-23
相关资源
相似解决方案