I am having a problem when trying to get jquery to close an open row in a table while opening another. I am trying to use toggle() to no avail and I know I am just missing something. Here is my html:
<table class="ProcTable" rules="all" cellpadding="0" cellspacing="0">
<thead>
<tr class="proctablerow">
<th>Recently Issued Procedures</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>Admin</td>
<td>User Name #1</td>
</tr>
<tr>
<td></td>
<td>Reader</td>
<td>User Name #2</td>
</tr>
<tr>
<td></td>
<td>Reader</td>
<td>User Name #3</td>
</tr>
</tbody>
</table>
<table class="ProcTable" rules="all" cellpadding="0" cellspacing="0">
<thead>
<tr class="proctablerow">
<th>Recently Viewed Procedures</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>Admin</td>
<td>User Name #1</td>
</tr>
<tr>
<td></td>
<td>Reader</td>
<td>User Name #2</td>
</tr>
<tr>
<td></td>
<td>Reader</td>
<td>User Name #3</td>
</tr>
</tbody>
</table>
<table class="ProcTable" rules="all" cellpadding="0" cellspacing="0">
<thead>
<tr class="proctablerow">
<th>Bookmarked Procedures</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>Admin</td>
<td>User Name #1</td>
</tr>
<tr>
<td></td>
<td>Reader</td>
<td>User Name #2</td>
</tr>
<tr>
<td></td>
<td>Reader</td>
<td>User Name #3</td>
</tr>
</tbody>
</table>
</table>
Here is my jquery code:
$(document).ready(function() {
$("#accordion").accordion( { active: false, collapsible: true });
$(".ProcTable").accordion( { active: false, collapsible: true, autoHeight: false });
$('table.ProcTable tr.proctablerow th') .click(
function() {
$(this) .parents('table.ProcTable') .children('tbody') .toggle();
});
});
Can someone help me figure out how to close one row while opening another row (accordion style). Thanks!
FIDDLE