Hello would someone help me out here?
I am trying to to do the following :
<table>
<thead>
<tr>
<th>Select</th>
<th>Name</th>
</tr>
</thead>
<tr>
<td>
<input type="checkbox" class="toggle">
</td>
<td>
Sam, Walls
</td>
</tr>
<tr class="show">
<td colspan="2">
This is the info about Sam.
</td>
</tr>
<tr>
<td>
<input type="checkbox" class="toggle">
</td>
<td>
John, Doe
</td>
</tr>
<tr class="show">
<td colspan="2">
This is the info about John.
</td>
</tr>
</table>
When the checkbox with class="toggle" is clicked I only want the row below it to appear.
My JavaScript code that does not work so well is as follows:
$('.show').hide();
$('.toggle').click(function(){
$('.show').slideToggle();
});
Currently it will only hide and toggle the Sam, Walls row.
EDIT : After using class instead of ID the hide issue seems to have been solved. Now however when I click one check box, both rows are toggled together. I updated the code above.
Any help would be appreciated!
Cheers.