I have been stuck with this problem for a while now. I know that for table rows to animate smoothly you need divs. And I came over this solution where I can hide the tablerow I want, but I cannot make it appear again.
I need some if solution or maybe some toggle solution.
HTML:
<table>
<tbody>
<tr>
<td class="clickme">
Sample text
</td>
<td class="clickme">$10</td>
<td class="clickme">$100</td>
<td class="clickme">$0</td>
</tr>
<tr class="hideme">
<td colspan="4">
<div>
Sample text, sample text, sample text, sample text, sample text, sample text
</div>
</td>
</tr>
<tr>
<td class="clickme">
Sample text
</td>
<td class="clickme">$10</td>
<td class="clickme">$100</td>
<td class="clickme">$0</td>
</tr>
<tr class="hideme">
<td colspan="4">
<div>
Sample text, sample text, sample text, sample text, sample text, sample text
</div>
</td>
</tr>
<tr>
<td class="clickme">
Sample text
</td>
<td class="clickme">$10</td>
<td class="clickme">$100</td>
<td class="clickme">$0</td>
</tr>
<tr class="hideme">
<td colspan="4">
<div>
Sample text, sample text, sample text, sample text, sample text, sample text
</div>
</td>
</tr>
<tr>
<td class="clickme">
Sample text
</td>
<td class="clickme">$10</td>
<td class="clickme">$100</td>
<td class="clickme">$0</td>
</tr>
<tr class="hideme">
<td colspan="4">
<div>
Sample text, sample text, sample text, sample text, sample text, sample text
</div>
</td>
</tr>
</tbody>
</table>
Jquery:
$('.hideme').find('div').hide();
$('.clickme').click(function() {
$(this).parent().next('.hideme').find('div').slideToggle(500);
return false;
});
The right markup and Jquery is updated. Final JSFiddle: http://jsfiddle.net/NVx4S/21/
1 Answer