日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

jquery --- 收缩兄弟元素

發布時間:2023/12/10 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 jquery --- 收缩兄弟元素 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


點擊高亮的收縮兄弟元素.
思路:
1.點擊的其實是tr.(類為parent)
2.toggleClass可以切換樣式
3.slblings(’.class’).toggle 可以根據其類來進行隱藏顯示

代碼如下:

<!DOCTYPE html> <html> <head> <meta charset="utf-8"><style>.parent{background: #fff38f;cursor: pointer;}.child{background: #ffe}.parent td{text-align: center;}.selected{background: red;} </style> </head> <body><table><thead><tr><th>姓名</th><th>性別</th><th>暫住地</th></tr></thead><tbody><tr class="parent" id="row01"><td colspan="3">前臺設計小組</td></tr><tr class="child row01"><td>張山</td><td>男</td><td>浙江寧波</td></tr><tr class="child row01"><td>李四</td><td>女</td><td>浙江杭州</td></tr><tr class="parent" id="row02"><td colspan="3">前臺開發組</td></tr><tr class="child row02"><td>王五</td><td>男</td><td>湖南長沙</td></tr><tr class="child row02"><td>趙六</td><td>女</td><td>浙江溫州</td></tr><tr class="parent" id="row03"><td colspan="3">后臺開發組</td></tr><tr class="child row03"><td>Rain</td><td>男</td><td>浙江杭州</td></tr><tr class="child row03"><td>MAXMAN</td><td>女</td><td>浙江杭州</td></tr></tbody></table><script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script> <script>$('.parent').click(function(){$(this).toggleClass('selected').siblings("." + this.id).toggle('100')}) </script></body> </html>

參考《鋒利的jQuery》(第2版)P160~P161

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的jquery --- 收缩兄弟元素的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。