Javascript hide table row
Home - Tutorials - Miscellaneous
This article demonstrates how you can hide table row with javascript and how you can show it again by pressing a button.
Tutorial info:
| Name: | Javascript hide table row |
| Total steps: | 3 |
| Category: | Miscellaneous |
| Date: | 2007-11-10 |
| Level: | Beginner |
| Product: | See complete product |
| Viewed: | 210424 |
Bookmark Javascript hide table row
Step 1 - Introduction
Javascript hide table row
Time to time it can happen that you want to make your html table more attractive and more interactive. Let's suppose you want to allow your visitors to hide and show some special rows in your table. Of course you are here because you want to do it without reloading the page. It is possible with javascript to hide table rows and show it again later if you want.
First of all lets create a basic and simple html 3x3 table where the first row contains the column captions. With the following html code:
Code:
<table width="300" border="1"> </table>
you will get a table like this:
| TH-1 | TH-2 | TH-3 |
|---|---|---|
| cell-11 | cell-12 | cell-13 |
| cell-21 | cell-22 | cell-23 |
Ok, that is our starting point. What we want is to add a button to the page to hide table rows. In this case we will hide the caption row.
To do this we will create a Javascript function which will be responsible for hiding and showing the row. Besides this we add a button to the page and it's onClick event will trigger the Javascript function.
Now it's time to make some real coding :)
Next Step of Javascript hide table row
Tags: javascript hide table row, javascript hide table, javascript hide row, hide table row
| Javascript hide table row - Table of contents |
|---|
| Step 1 - Introduction |
| Step 2 - Hide the row |
| Step 3 - Javascript hide row example and code |