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)
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/webkaifa/)ID | Name | Total | 123Bill Gates100 2007-01-02A short description15 2007-02-03Another description45 2007-03-04More Stuff40456Bill Brasky50 2007-01-02A short description10 2007-02-03Another description20 2007-03-04More Stuff20789Phil Upspace75 2007-01-02A short description33 2007-02-03Another description22 2007-03-04More Stuff20