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
https://forums.phpfreaks.com/topic/95938-help-on-showhide-content/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.