jQuery實現(xiàn)的checkbox級聯(lián)選擇下拉菜單效果示例
本文實例講述了jQuery實現(xiàn)的checkbox級聯(lián)選擇下拉菜單效果。分享給大家供大家參考,具體如下:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title></title> <script language="JavaScript" src="jquery-1.4.2.min.js"></script> </head> <body> <!--table 一行一列:table 三行一列:table 一行一列:table 三行一列:table--> <table width="156"> <tr> <td> <table width="152"> <tr width="152"> <td> <table width="152"> <tr> <td> <table width="98%" align="center"> <tr style="color:red;background:blue" onClick="show('1') "> <td><img src="./ui/images/yonghu.png"></td> <td>用戶管理</td> <td><img src="./ui/images/zhankai.png"></td> </tr> </table> </td> </tr> <tr id="tr0_1" style="DISPLAY: none"> <td> <table width="90%" align="center"> <tr> <td><img src="./ui/images/yonghuxinxi.png"></td> <td>用戶信息</td> </tr> </table> <table width="90%" align="center"> <tr> <td><img src="./ui/images/juesequanxian.png"></td> <td>角色權限</td> </tr> </table> </td> </tr> </table> </td> </tr> <tr width="152"> <td> <table width="152"> <tr> <td> <table width="98%" align="center"> <tr style="color:red;background:blue" onClick="show('2') "> <td><img src="./ui/images/kehu.png"></td> <td>客戶管理</td> <td><img src="./ui/images/zhankai.png"></td> </tr> </table> </td> </tr> <tr id="tr0_2" style="DISPLAY: none"> <td><!-- 一列兩個table--> <table width="90%" align="center"> <tr> <td><img src="./ui/images/kehuxinxi.png"></td> <td>客戶信息</td> </tr> </table> <table width="90%" align="center"> <tr> <td><img src="./ui/images/lianxiren.png"></td> <td>聯(lián)系人列表</td> </tr> </table> </td> </tr> </table> </td> </tr> <tr width="152"> <td> <table width="152"> <tr> <td> <table width="98%" align="center"> <tr style="color:red;background:blue" onClick="show('3')"> <td><img src="./ui/images/xitong.png"></td> <td>系統(tǒng)管理</td> <td><img src="./ui/images/zhankai.png"></td> </tr> </table> </td> </tr> <tr id="tr0_3" style="DISPLAY: none"> <td> <table width="90%" align="center"> <tr> <td><img src="./ui/images/xitongrizhi.png"></td> <td>系統(tǒng)日志</td> </tr> </table> <table width="90%" align="center"> <tr> <td><img src="./ui/images/shujuzidian.png"></td> <td>數(shù)據(jù)字典</td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </body> <script language="JavaScript"> <!--js dom: 根據(jù)tr0_id, id的值,進行操作。得到tr的length,遍歷,判斷id值,根據(jù)傳入的id值,拼裝tr0_id,--> <!--拿到對應的tr元素,設置 顯示或隱藏 --> function show(id){ //使用循環(huán)遍歷找到需要控制的所有隱藏的tr var $tr = $("tr[id^='tr0']"); // alert($tr.length); $tr.each(function(index,domEle){ //查找當前onclick操作的tr //檢查 每次循環(huán)遍歷 操作要對應的tr,隱藏的,就三個,看看是哪一個 // if(id==index+1){ //如果當前的tr處于隱藏狀態(tài),就得顯示 if($(this).is(":hidden")){ $(this).attr("style","DISPLAY: block"); } //如果當前的tr處于顯示狀態(tài),就得隱藏 else{ $(this).attr("style","DISPLAY: none"); } } <!--把其他的打開的 隱藏 每次都會遍歷--> else{ //將不選擇的tr都隱藏 $(domEle).attr("style","DISPLAY: none"); } }) } </script> </html>
更多關于jQuery相關內容感興趣的讀者可查看本站專題:《jQuery表格(table)操作技巧匯總》、《jQuery切換特效與技巧總結》、《jQuery擴展技巧總結》、《jQuery常用插件及用法總結》、《jQuery拖拽特效與技巧總結》、《jquery中Ajax用法總結》、《jQuery常見經典特效匯總》、《jQuery動畫與特效用法總結》及《jquery選擇器用法總結》
希望本文所述對大家jQuery程序設計有所幫助。
相關文章
jQuery實現(xiàn)圖片隨機切換、抽獎功能(實例代碼)
本文通過實例代碼給大家介紹了jQuery實現(xiàn)圖片隨機切換、抽獎功能,感興趣的朋友跟隨小編一起看看吧2019-10-10jQuery UI Dialog 創(chuàng)建友好的彈出對話框實現(xiàn)代碼
jQuery UI Dialog是jQuery UI的彈出對話框組件,使用它可以創(chuàng)建各種美觀的彈出對話框;它可以設置對話框的標題、內容,并且使對話框可以拖動、調整大小、及關閉;平常主要用來替代瀏覽囂自帶的alert、confirm、open等方法2012-04-04為JQuery EasyUI 表單組件增加焦點切換功能的方法
下面小編就為大家?guī)硪黄獮镴Query EasyUI 表單組件增加焦點切換功能的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-04-04jQuery遍歷DOM的父級元素、子級元素和同級元素的方法總結
借助jQuery我們可以輕松地堆DOM元素進行向上、向下遍歷以及同級的遍歷,本文我們即來整理jQuery遍歷DOM的父級元素、子級元素和同級元素的方法總結:2016-07-07