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

Javascript
javascript实现的鼠标链接提示效果生成器代码
javascript实现动态CSS换肤技术的脚本
一个即时表单验证的javascript代码
javascript之dhDataGrid Ver2.0.0代码
syntaxhighlighter 使用方法
建立良好体验度的Web注册系统ajax
抽出www.templatemonster.com的鼠标悬停加载大图模板的代码
JTrackBar水平拖动效果
用JTrackBar实现的模拟苹果风格的滚动条
非常不错的javascript 图片慢慢下层效果
网上应用的一个不错common.js脚本
alixixi runcode.asp的代码不错的应用
用javascript实现点击链接弹出"图片另存为"而不是直接打开
用javascript实现给图片加链接
document.styleSheets[0].rules 与 cssRules区别
javascript 控制超级链接的样式代码
一个刚完成的layout(拖动流畅,不受iframe影响)
写了一个layout,拖动条连贯,内容区可为iframe
用JS实现网页元素阴影效果的研究总结
js下在password表单内显示提示信息的解决办法

Javascript 中的 Expandable "Detail" Table Rows


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 64 ::
收藏到网摘: 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