title: how do I stay in the selected tab during a postback by jquery?
body: <p>I have following jquery to set the selected tab as active tab, but it is not quite working. Can anybody help me out there? Basically I used a hidden field to save the selected tab, and in the ready function I set it to active.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          $(document).ready(function() {
              var tab = $get('selected_tab').value;
  
              //When page loads...
              $(".tab_content").hide(); //Hide all content
              $("ul.tabs li:tab").addClass("active").show(); //Activate first tab
              $(".tab_content:tab").show(); //Show first tab content
  
              //On Click Event
              $("ul.tabs li").click(function() {
  
                  $("ul.tabs li").removeClass("active"); //Remove any "active" class
                  $(this).addClass("active"); //Add "active" class to selected tab
                  $(".tab_content").hide(); //Hide all tab content
  
                  var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
                  $(activeTab).fadeIn(); //Fade in the active ID content
                  return false;
              });
  
          });
    &lt;/script&gt;  
  
  &lt;div id="content"&gt;
   &lt;input typE="hidden" id="selected_tab" name="selected_tab" value="0" /&gt;
   &lt;ul class="tabs"&gt;
      &lt;li&gt;&lt;a href="#tab1" onclick="document.getElementById('selected_tab').value=0;"&gt;Details&lt;/a&gt;&lt;/li&gt; 
      &lt;li&gt;&lt;a href="#tab2" onclick="document.getElementById('selected_tab').value=1;"&gt;History&lt;/a&gt;&lt;/li&gt; 
      &lt;li&gt;&lt;a href="#attachmentcontent" onclick="document.getElementById('selected_tab').value=2;"&gt;Attachments&lt;/a&gt;&lt;/li&gt; 
      &lt;/ul&gt;
  </code></pre>