boneXXX Posted March 13, 2008 Share Posted March 13, 2008 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.