网络编程 
首页 > 网络编程 > 浏览文章

Expandable "Detail" Table Rows

(编辑:jimmy 日期: 2025/5/11 浏览:3 次 )

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
上一篇:用javascript实现给出的盒子的序列是否可连为一矩型
下一篇:出现“不能执行已释放的Script代码”错误的原因及解决办法
一句话新闻
Windows上运行安卓你用过了吗
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 网站地图 SiteMap