You cannot mix <div> with <table> like this, use additional <tbody> elements <tbody> . In your callback, this is a <td> element that has no siblings, so .next doesn't help anything; you want to go back until you reach what is at the same depth as .section , you are interested in, and then call .next from there.
Your HTML should look like this:
<table id="main_table"> <thead> <tr class="firstline"> <th>Column1</th> <th>Column2</th> <th>Column3</th> <th>Column4</th> </tr> </thead> <tbody> <tr style="background-color:green; color:white"> <td colspan="4" class="flip"> Section 1 </td> </tr> </tbody> <tbody class="section"> <tr> <td>item 111</td> <td>item 112</td> <td>item 113</td> <td>item 114</td> </tr>
And your click handler looks like this:
$('.flip').click(function() { $(this) .closest('tbody') .next('.section') .toggle('fast'); });
.closest returns your ancestors until it finds a <tbody> , and then you call .next .
Updated jsfiddle: http://jsfiddle.net/ambiguous/Udxyb/4/
mu is too short
source share