title: How to hide content of a tab in a jsp page
body: <p>I have a jsp page with 4 tabs. Suppose tab1,tab2,tab3,tab4. Each tab has their own buttons,button1 for tab1 and similarly button2 for tab2,button3 for tab3 and button4 for tab4. When I click tab1,it should show me the content of only tab1 and other buttons of remaining tabs should not be displayed.My issue is when I click tab1 it is showing me the buttons of tab1 ie button1 which is correct but when I click the button1 to get the required output, the webpage is displaying the buttons of the remaining tabs ie button2,button3,button4 along with the content of the tabl which is incorrect . Below is the small code snippet am using.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function tab(tab) {
      document.getElementById("start").style.display = "none";
      document.getElementById("status").style.display = "none";
      document.getElementById("log").style.display = "none";
      document.getElementById("checkin/checkout").style.display = "none";
      document.getElementById("version").style.display = "none";
      document.getElementById("li_start").setAttribute("class", "");
      document.getElementById("li_status").setAttribute("class", "");
      document.getElementById("li_log").setAttribute("class", "");
      document.getElementById("li_checkin/checkout").setAttribute("class", "");
      document.getElementById("li_version").setAttribute("class", "");
      document.getElementById(tab).style.display = "block";
      document.getElementById("li_"+tab).setAttribute("class", "active");
      }
      &lt;/script&gt;
  
      &lt;div id="tabs" align="center"&gt;
      &lt;ul&gt;
          &lt;li id="li_start" onclick="tab  
  ('start')"&gt;&lt;a&gt;Start/Stop/Reread&lt;/a&gt;&lt;/li&gt;
          &lt;li id="li_status" onclick="tab('status')"&gt;&lt;a&gt;Server 
     Status&lt;/a&gt;&lt;/li&gt;
          &lt;li id="li_log" onclick="tab('log')"&gt;&lt;a&gt;View Log&lt;/a&gt;&lt;/li&gt;
          &lt;li id="li_version" onclick="tab('version')"&gt;&lt;a&gt;Version&lt;/a&gt;&lt;/li&gt;
          &lt;li id="li_checkin/checkout" onclick="tab
  ('checkin/checkout')"&gt;&lt;a&gt;Checkin/Checkout Feature&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  
      &lt;div id="Content_Area"&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div id="log" onclick="document.getElementById('log').style.display = 'block';"&gt;
  
  &lt;table align="center"&gt;&lt;tr&gt;&lt;td&gt;&lt;h2&gt;LogFile&lt;/h2&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
  
  &lt;table width="500px" align="center" style="border:1px solid #000000;background-  
  color:#efefef;"&gt;
  
  &lt;tr&gt;&lt;td colspan=2&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td colspan=2&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;&lt;b&gt;LogFile&lt;/b&gt;&lt;/td&gt;
  
      &lt;td&gt;
                              &lt;FORM 
  action="logfile" METHOD="POST"&gt;
                                  &lt;input 
  type=submit name=showLog id=txtSubmit value="ViewLog" /&gt;
  
                              &lt;/FORM&gt;
  
                          &lt;div id="result"&gt;
                              &lt;pre&gt;
      ${requestScope.logOutput}
  &lt;/pre&gt;
                          &lt;/div&gt;&lt;/td&gt;
  
  &lt;/tr&gt;
  
  
  &lt;tr&gt;&lt;td colspan=2&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
  
  &lt;/table&gt;
  </code></pre>
  
  <h2>    </h2>
  
  <p>code with jquery:</p>
  
  <pre><code>    pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
  </code></pre>
  
  <p>
      </p>
  
  <pre><code>&lt;title&gt;JavaScript tabs example&lt;/title&gt;
  
  &lt;style type="text/css"&gt;
    body { font-size: 80%; font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif; }
    ul#tabs { list-style-type: none; margin: 30px 0 0 0; padding: 0 0 0.3em 0; }
    ul#tabs li { display: inline; }
    ul#tabs li a { color: #42454a; background-color: #dedbde; border: 1px solid     
  #c9c3ba;     border-bottom: none; padding: 0.3em; text-decoration: none; }
    ul#tabs li a:hover { background-color: #f1f0ee; }
    ul#tabs li a.selected { color: #000; background-color: #f1f0ee; font-weight: bold;  
  padding: 0.7em 0.3em 0.38em 0.3em; }
    div.tabContent { border: 1px solid #c9c3ba; padding: 0.5em; background-color: 
  #f1f0ee; }
    div.tabContent.hide { display: none; }
  &lt;/style&gt;
  
  &lt;script type="text/javascript"&gt;
  //&lt;![CDATA[
  
  var tabLinks = new Array();
  var contentDivs = new Array();
  
  function init() {
  
    // Grab the tab links and content divs from the page
    var tabListItems = document.getElementById('tabs').childNodes;
    for ( var i = 0; i &lt; tabListItems.length; i++ ) {
      if ( tabListItems[i].nodeName == "LI" ) {
        var tabLink = getFirstChildWithTagName( tabListItems[i], 'A' );
        var id = getHash( tabLink.getAttribute('href') );
        tabLinks[id] = tabLink;
        contentDivs[id] = document.getElementById( id );
      }
    }
  
    // Assign onclick events to the tab links, and
    // highlight the first tab
    var i = 0;
  
    for ( var id in tabLinks ) {
      tabLinks[id].onclick = showTab;
      tabLinks[id].onfocus = function() { this.blur() };
     // if ( i == 0 ) tabLinks[id].className = 'selected';
      i++;
    }
  
    // Hide all content divs except the first
    var i = 0;
  
    for ( var id in contentDivs ) {
      if ( i != 0 ) contentDivs[id].className = 'tabContent hide';
      i++;
    }
  }
  
  function showTab() {
    var selectedId = getHash( this.getAttribute('href') );
  
    // Highlight the selected tab, and dim all others.
    // Also show the selected content div, and hide all others.
    for ( var id in contentDivs ) {
      if ( id == selectedId ) {
        tabLinks[id].className = 'selected';
        contentDivs[id].className = 'tabContent';
      } else {
        tabLinks[id].className = '';
        contentDivs[id].className = 'tabContent hide';
      }
    }
  
    // Stop the browser following the link
    return false;
  }
  
  function getFirstChildWithTagName( element, tagName ) {
    for ( var i = 0; i &lt; element.childNodes.length; i++ ) {
      if ( element.childNodes[i].nodeName == tagName ) return element.childNodes[i];
    }
  }
  
  function getHash( url ) {
    var hashPos = url.lastIndexOf ( '#' );
    return url.substring( hashPos + 1 );
  }
  
  //]]&gt;
  &lt;/script&gt;
    &lt;/head&gt;
    &lt;body onload="init()"&gt;
  &lt;h1&gt;JavaScript tabs example&lt;/h1&gt;
  
  &lt;ul id="tabs"&gt;
    &lt;li&gt;&lt;a href="#start"&gt;Start/Stop/ReRead&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#status"&gt;ServerStatus&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#logs"&gt;ViewLog&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#version"&gt;Version&lt;/a&gt;&lt;/li&gt;
  
  &lt;/ul&gt;
  
  &lt;div class="tabContent" id="start"&gt;
    &lt;h2&gt;ServerStart&lt;/h2&gt;
    &lt;div&gt;
      &lt;p&gt;JavaScript tabs partition your Web page content into tabbed sections.      p&gt;
      &lt;p&gt;The code is written in such a way that the page degrades gracefully in bro.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="tabContent" id="status"&gt;
    &lt;h2&gt;Status&lt;/h2&gt;
    &lt;div&gt;
      &lt;p&gt;JavaScript tabs are great if your Web page contains a large amount of cont.&lt;/p&gt;
      &lt;p&gt;They're also good for things like multi-step Web forms.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="tabContent" id="logs"&gt;
    &lt;h2&gt;Logfile&lt;/h2&gt;
    &lt;div&gt;
      &lt;p&gt;Click a tab to view the tab's content. Using tabs couldn't be easier!&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="tabContent" id="version"&gt;
    &lt;h2&gt;Version&lt;/h2&gt;
    &lt;div&gt;
      &lt;form action="version" method="post"&gt;
                                  &lt;p&gt;&lt;input type=submit name=findversion id=txtSubmit
                                      value=FindVersion /&gt;
  </code></pre>
  
  <p></p>
                                  </p>
  
  <pre><code>                        &lt;div id="result"&gt;
                              &lt;pre&gt;
      ${requestScope.verOutput}
  &lt;/pre&gt;
                          &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>