title: Losing css class added through jquery on updatepanel partial postback
body: <p>I'm using ASP.NET Ajax with JQuery.  I have a click event that adds/removes css classes on objects in an UpdatePanel, but when the ASP.NET Partial postback occurs, I lose the "state."  Here is minimal example I tried to create; how do I keep the css class state? </p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
  
      &lt;style type="text/css"&gt;
          .active { background: #000000; color: #ffffff; }
          .test {}
      &lt;/style&gt;
  
  
      &lt;script src="jquery-1.3.2.js" type="text/javascript"&gt;&lt;/script&gt; 
  
      &lt;script language="javascript" type="text/javascript"&gt;
  
          function pageLoad(sender, args) {
  
              // rebind events lost in partial postback
              $(".test").unbind();
  
              $(".test").click(function() {
  
                  $(".test").removeClass("active");
                  $(this).addClass("active");
  
              });
  
          }
  
      &lt;/script&gt;
  
  
  
  
  
  
  
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
  
  
      &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
      &lt;/asp:ScriptManager&gt;
  
      &lt;asp:Timer ID="Timer1" runat="server" Interval="30000" ontick="Timer1_Tick"&gt;
      &lt;/asp:Timer&gt;
  
      &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
  
      &lt;Triggers&gt;
      &lt;asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /&gt;
      &lt;/Triggers&gt;
  
      &lt;ContentTemplate&gt;
  
  
      &lt;div class="test"&gt;
  
          &lt;asp:Label ID="Label1" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
  
      &lt;/div&gt;
  
  
      &lt;div class="test"&gt;
  
          &lt;asp:Label ID="Label2" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
  
      &lt;/div&gt;
  
      &lt;/ContentTemplate&gt;
      &lt;/asp:UpdatePanel&gt;
  
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>