hide table body by default
Hello,
I'm trying to hide the table body of all tables on my html page. By default they are shown, but I want them hidden. Since the ID for each table on my html page will differ, I need some way to collapse them all on pageload, because all I can seem to manage is to have them expanded by default. Any help is appreciated.
javascript:
- function togglePanelMore(id, source) {
- var viewContainer = $(id);
- if ($(source).html() == "showrows") {
- $(source).html("hiderows");
- viewContainer.show();
- }
- else {
- $(source).html("showrows");
- viewContainer.hide();
- }
- }
html:
- <table summary="example" id="box-table-a">
- <thead>
- <tr>
- <th scope="col" colspan="2"><a href="javascript:togglePanelMore('#row01', '#togglerow01')" id="togglerow01">hiderows</a></th>
- </tr>
- </thead>
- <tbody id="row01">
- <tr>
- <td>Telefoonnummer</td>
- <td>011 23 45 67</td>
- </tr>
- <tr>
- <td>Faxnummer</td>
- <td>011 23 45 68</td>
- </tr>
- <tr>
- <td>E-mailadres</td>
- <td>info@someaddress.com</td>
- </tr>
- <tr>
- <td>Website</td>
- <td>www.someaddress.com</td>
- </tr>
- </tbody>
- </table>