Jump to content

Help on Show/Hide Content


boneXXX

Recommended Posts

Hi, I have a code sample to show&hide contents http://www.javascriptf1.com/tutorial/javascript-hide-table-row.html?page=3

 

but I need a help on modifying the code to hide the content at default, show it when the button is clicked. At the the moment, when the page is loaded content is visible and it gets hide when it is clicked. Could you help me on this please? thanks

 

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">

      <head>

      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

      <title>Javascript hide table row</title>
  
      </head>

       

      <body>

      <script type="text/javascript">

      function displayRow(){

      var row = document.getElementById("captionRow");

      if (row.style.display == '') row.style.display = 'none';

      else row.style.display = '';

      }

      </script>

       

      <table width="300" border="1">

      <tr id="captionRow"><th>TH-1</th><th>TH-2</th><th>TH-3</th></tr>

      <tr><td>cell-11</td><td>cell-12</td><td>cell-13</td></tr>

      <tr><td>cell-21</td><td>cell-22</td><td>cell-23</td></tr>

      </table>

      <p><button onclick="displayRow()" >Show / Hide</button></p>

      </body>

      </html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.