Expandable "Detail" Table Rows
A common UI is to have a table of data rows, which when clicked on expand to show a detailed breakdown of "child" rows below the "parent" row.
The only requirements are:
Put a class of "parent" on each parent row (tr)
Give each parent row (tr) an id
Give each child row a class of "child-ID" where ID is the id of the parent tr that it belongs to
Example Code
$(function() {
$('tr.parent')
.css("cursor","pointer")
.attr("title","Click to expand/collapse")
.click(function(){
$(this).siblings('.child-'+this.id).toggle();
});
$('tr[@class^=child-]').hide().children('td');
});Example Table (click a row)
| ID | Name | Total | |
|---|---|---|---|
| 123 | Bill Gates | 100 | |
| 2007-01-02 | A short description | 15 | |
| 2007-02-03 | Another description | 45 | |
| 2007-03-04 | More Stuff | 40 | |
| 456 | Bill Brasky | 50 | |
| 2007-01-02 | A short description | 10 | |
| 2007-02-03 | Another description | 20 | |
| 2007-03-04 | More Stuff | 20 | |
| 789 | Phil Upspace | 75 | |
| 2007-01-02 | A short description | 33 | |
| 2007-02-03 | Another description | 22 | |
| 2007-03-04 | More Stuff | 20 | |
相關(guān)文章
jQuery實(shí)現(xiàn)列表自動(dòng)滾動(dòng)循環(huán)滾動(dòng)展示新聞
jQuery實(shí)現(xiàn)列表自動(dòng)滾動(dòng)循環(huán)滾動(dòng)展示新聞,鼠標(biāo)懸停時(shí)停止?jié)L動(dòng)并提示,離開后,繼續(xù)滾動(dòng),實(shí)現(xiàn)的代碼如下,需要的朋友可以看看2014-08-08
JavaScript中利用jQuery綁定事件的幾種方式小結(jié)
這篇文章主要介紹了JavaScript中利用jQuery綁定事件的幾種方式小結(jié),包括不調(diào)用jQuery的"原生js"實(shí)現(xiàn)方式,需要的朋友可以參考下2016-03-03
jQuery通過ajax請(qǐng)求php遍歷json數(shù)組到table中的代碼(推薦)
這篇文章主要介紹了jQuery通過ajax請(qǐng)求php遍歷json數(shù)組到table中代碼(推薦)的相關(guān)資料,非常不錯(cuò)具有參考借鑒價(jià)值,需要的朋友可以參考下2016-06-06
jQuery+HTML5實(shí)現(xiàn)手機(jī)搖一搖換衣特效
經(jīng)常我們玩微信都會(huì)用到查到附近的人,都是在app上實(shí)現(xiàn)手機(jī)搖一搖的功能?,F(xiàn)在,我們將此技術(shù)搬移到手機(jī)web上,供大家學(xué)習(xí),有需要的小伙伴可以參考下。2015-06-06
jquery select 設(shè)置默認(rèn)選中的示例代碼
本篇文章主要是對(duì)jquery select 設(shè)置默認(rèn)選中的示例代碼進(jìn)行了介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助2014-02-02
jquery實(shí)時(shí)獲取時(shí)間的簡(jiǎn)單實(shí)例
下面小編就為大家?guī)硪黄猨query實(shí)時(shí)獲取時(shí)間的簡(jiǎn)單實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-01-01
基于Jquery+Ajax+Json實(shí)現(xiàn)分頁(yè)顯示附效果圖
后臺(tái)action產(chǎn)生json數(shù)據(jù),js獲取json數(shù)據(jù)分頁(yè)顯示,詳細(xì)的示例代碼如下,需要的朋友可以學(xué)習(xí)下2014-07-07
textarea中的手動(dòng)換行處理的jquery代碼
textarea的手動(dòng)換行會(huì)產(chǎn)生換行標(biāo)志,但這個(gè)標(biāo)志存在卻看不到,存入數(shù)據(jù)庫(kù)中后讀出來顯示在頁(yè)面上卻不會(huì)換行,如何處理呢?2011-02-02
基于jquery的simpleValidate簡(jiǎn)易驗(yàn)證插件
簡(jiǎn)易驗(yàn)證插件simpleValidate使用心得,基于JQuery,修改小BUG后能兼容各瀏覽器,附自用版本供下載2014-01-01

