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

Expandable "Detail" Table Rows

(编辑:jimmy 日期: 2025/12/27 浏览: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代码”错误的原因及解决办法
一句话新闻
微软与英特尔等合作伙伴联合定义“AI PC”:键盘需配有Copilot物理按键
几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 网站地图 SiteMap