当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Expandable "Detail" Table Rows

Javascript
手把手教你做超酷的条形码效果
pjblog中的UBBCode.js
一个跟随鼠标的图片放大效果,与FF兼容
学习jquery之一
javascript英文日期(有时间)选择器
几行代码轻松搞定jquery实现flash8类似的连接效果
搜集了几个不错的下拉菜单效果
无间断滚动的新闻文章列表,兼容IE、Firefox和Opera,符合W3C标准。可作Marquee
一个js实现的所谓的滑动门
OfflineSave离线保存代码再次发布使用说明
css静态滤镜 + A:Hover 效果
js+ajax实现的A*游戏路径算法整理
JSON 学习之完全手册 图文
Javascript & DHTML 实例编程(教程)(四)初级实例篇2—动画
jQuery基础学习技巧总结
jQuery 中关于CSS操作部分使用说明
经常用的图片在容器中的水平垂直居中实例
比较不错的一款图片广告效果
用javascript实现的汉字简繁转换
javascript实现的文字加密解密

Javascript 中的 Expandable "Detail" Table Rows


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 69 ::
收藏到网摘: n/a

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