title: jQuery CSS changes lost after ASP.NET AJAX asynchronous postback
body: <p>I have the following in C#:</p>
  
  <pre><code>&lt;asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"&gt;
      &lt;ContentTemplate&gt;
          &lt;span id="header" class="hideMe"&gt;
              (other irrelevant tags and controls)
          &lt;/span&gt;
          &lt;div&gt;
              (other irrelevant tags and controls)
          &lt;/div&gt;
          &lt;asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" /&gt;
      &lt;/ContentTemplate&gt;
      &lt;Triggers&gt;
          &lt;asp:AsyncPostBackTrigger ControlID="btnSubmit" /&gt;
      &lt;/Triggers&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>And the following jQuery</p>
  
  <pre><code>if ($) {
    $(document).ready(function () {
  
      $('#header').click(function ($e) {
        if ($(this).hasClass('hideMe')) {
          $('#header').removeClass('hideMe');
          $('#header').addClass('showMe');
        }
        else {
          $('#header').removeClass('showMe');
          $('#header').addClass('hideMe');
        }
      }
  
    });
  }
  </code></pre>
  
  <p>The jQuery works just fine (ie - if I click upon the header span and the hideMe class is current then it'll remove hideMe and add showMe, and vice-versa).</p>
  
  <p><strong>However, when I click upon the btnSubmit then an asynchronous postback occurs and causes the header span to reset to its original state (which would be with the hideMe class applied).</strong></p>
  
  <p>How do I go about getting the header span to remain in the state that it was when the submit button is clicked and to not revert back to the state that it was at page load?</p>