jQuery之排他思想

使用的方法: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>

 

posted @ 2019-11-29 10:23  遥望那月  阅读(2715)  评论(0编辑  收藏  举报