Of course you can do it with jQuery. I would do it like this:
<table>
<tbody id="new">
<tr>...</tr>
<tr><td><a href="#" id="toggle">Show Old</a></td></tr>
</tbody>
<tbody id="old">
...
</tbody>
</table>
Download them using CSS:
#old { display: none; }
and
$(function() {
$("#toggle").click(function() {
if ($("#old").is(":hidden")) {
$(this).text("Hide Old");
} else {
$(this).text("Show Old");
}
$("#old").slideToggle();
return false;
});
});
The effects of hide / show jQuery can be a little weird with table components. If so, change the CSS to this:
#old.hidden { display: none; }
and
$(function() {
$("toggle").click(function() {
if ($("#old").hasClass("hidden")) {
$(this).text("Hide Old");
} else {
$(this).text("Show Old");
}
$(this).toggleClass("hidden");
return false;
});
});
Of course, you will not get nice effects this way.
source
share