title: check if checkbox is checked using jQuery then add a class to the closest td
body: <p>i'm using ASP.NET ,i have a gridview with a checkbox element , i want to check if checkbox is checked add a class to the clossest td that can change the background-color to black </p>
  
  <p>i use this but it does not work : </p>
  
  <p>Js ((Purpose of Tasting)) :</p>
  
  <pre><code>    $(document).ready(function () {
  
      $(":CheckBox").closest('td').addClass("OnSelectTr");
  });
  </code></pre>
  
  <p>CSS :</p>
  
  <pre><code>.OnSelectTr
  {
      background-color:Black;
  }
  </code></pre>
  
  <p>ASP.NET CODE : </p>
  
  <pre><code>&lt;asp:GridView ID="DossierGV" runat="server" AllowPaging="True" 
                              AllowSorting="True" DataSourceID="DossierPF" AutoGenerateColumns="False" 
                              DataKeyNames="ID_Dossier"&gt;
                            &lt;Columns&gt;
                                &lt;asp:TemplateField HeaderText="Choisir"&gt;
                                    &lt;EditItemTemplate&gt;
                                        &lt;asp:CheckBox ID="CheckBox1" runat="server" /&gt;
                                    &lt;/EditItemTemplate&gt;
                                    &lt;ItemTemplate&gt;
                                        &lt;asp:CheckBox ID="CheckBox1" runat="server" /&gt;
                                    &lt;/ItemTemplate&gt;
                                &lt;/asp:TemplateField&gt;
                                &lt;asp:BoundField DataField="ID_Dossier" HeaderText="ID_Dossier" ReadOnly="True" 
                                    SortExpression="ID_Dossier" /&gt;
                                &lt;asp:BoundField DataField="ID_Entreprise" HeaderText="ID_Entreprise" 
                                    SortExpression="ID_Entreprise" /&gt;
                                &lt;asp:BoundField DataField="Date_Depot" HeaderText="Date_Depot" 
                                    SortExpression="Date_Depot" /&gt;
                                &lt;asp:BoundField DataField="Type_Etude" HeaderText="Type_Etude" 
                                    SortExpression="Type_Etude" /&gt;
                                &lt;asp:BoundField DataField="Dernier_Type" HeaderText="Dernier_Type" 
                                    SortExpression="Dernier_Type" /&gt;
                                &lt;asp:BoundField DataField="Eligibile" HeaderText="Eligibile" 
                                    SortExpression="Eligibile" /&gt;
                                &lt;asp:BoundField DataField="Fiche_Information" HeaderText="Fiche_Information" 
                                    SortExpression="Fiche_Information" /&gt;
                                &lt;asp:BoundField DataField="Buletin_Adhesion" HeaderText="Buletin_Adhesion" 
                                    SortExpression="Buletin_Adhesion" /&gt;
                                &lt;asp:BoundField DataField="Fiche_Renseignment" HeaderText="Fiche_Renseignment" 
                                    SortExpression="Fiche_Renseignment" /&gt;
                                &lt;asp:BoundField DataField="Attestation" HeaderText="Attestation" 
                                    SortExpression="Attestation" /&gt;
                                &lt;asp:BoundField DataField="ID_Cabinet" HeaderText="ID_Cabinet" 
                                    SortExpression="ID_Cabinet" /&gt;
                                &lt;asp:BoundField DataField="Montant_Demander" HeaderText="Montant_Demander" 
                                    SortExpression="Montant_Demander" /&gt;
                                &lt;asp:BoundField DataField="Duree" HeaderText="Duree" SortExpression="Duree" /&gt;
                                &lt;asp:BoundField DataField="Porcentage_Taux" HeaderText="Porcentage_Taux" 
                                    SortExpression="Porcentage_Taux" /&gt;
                                &lt;asp:BoundField DataField="Nom_Giac" HeaderText="Nom_Giac" 
                                    SortExpression="Nom_Giac" /&gt;
                            &lt;/Columns&gt;
                        &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>code source in the navigator : </p>
  
  <pre><code>&lt;div class="GridViewDiv"&gt;
  
                &lt;div id="Corps_DossierUpdatePanel"&gt;
                        &lt;div&gt;
  
          &lt;table cellspacing="0" rules="all" border="1" id="Corps_DossierGV" style="border-collapse:collapse;"&gt;
  
              &lt;tr&gt;
                  &lt;th scope="col"&gt;Choisir&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$Corps$DossierGV&amp;#39;,&amp;#39;Sort$ID_Dossier&amp;#39;)"&gt;ID_Dossier&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$Corps$DossierGV&amp;#39;,&amp;#39;Sort$ID_Entreprise&amp;#39;)"&gt;ID_Entreprise&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$Corps$DossierGV&amp;#39;,&amp;#39;Sort$Date_Depot&amp;#39;)"&gt;Date_Depot&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$Corps$DossierGV&amp;#39;,&amp;#39;Sort$Type_Etude&amp;#39;)"&gt;Type_Etude&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$Corps$DossierGV&amp;#39;,&amp;#39;Sort$Dernier_Type&amp;#39;)"&gt;Dernier_Type&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$Corps$DossierGV&amp;#39;,&amp;#39;Sort$Eligibile&amp;#39;)"&gt;Eligibile&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$Corps$DossierGV&amp;#39;,&amp;#39;Sort$Fiche_Information&amp;#39;)"&gt;Fiche_Information&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$Corps$DossierGV&amp;#39;,&amp;#39;Sort$Buletin_Adhesion&amp;#39;)"&gt;Buletin_Adhesion&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$Corps$DossierGV&amp;#39;,&amp;#39;Sort$Fiche_Renseignment&amp;#39;)"&gt;Fiche_Renseignment&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$Corps$DossierGV&amp;#39;,&amp;#39;Sort$Attestation&amp;#39;)"&gt;Attestation&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$Corps$DossierGV&amp;#39;,&amp;#39;Sort$ID_Cabinet&amp;#39;)"&gt;ID_Cabinet&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$Corps$DossierGV&amp;#39;,&amp;#39;Sort$Montant_Demander&amp;#39;)"&gt;Montant_Demander&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$Corps$DossierGV&amp;#39;,&amp;#39;Sort$Duree&amp;#39;)"&gt;Duree&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$Corps$DossierGV&amp;#39;,&amp;#39;Sort$Porcentage_Taux&amp;#39;)"&gt;Porcentage_Taux&lt;/a&gt;&lt;/th&gt;&lt;th scope="col"&gt;&lt;a href="javascript:__doPostBack(&amp;#39;_ctl0$Corps$DossierGV&amp;#39;,&amp;#39;Sort$Nom_Giac&amp;#39;)"&gt;Nom_Giac&lt;/a&gt;&lt;/th&gt;
  
              &lt;/tr&gt;&lt;tr&gt;
  
                  &lt;td&gt;
  
                                        &lt;input id="Corps_DossierGV_CheckBox1_0" type="checkbox" name="_ctl0:Corps:DossierGV:_ctl2:CheckBox1" /&gt;
  
                                    &lt;/td&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;10/12/2011 00:00:00&lt;/td&gt;&lt;td&gt;DS&lt;/td&gt;&lt;td&gt;IN&lt;/td&gt;&lt;td&gt;oui&lt;/td&gt;&lt;td&gt;oui&lt;/td&gt;&lt;td&gt;oui&lt;/td&gt;&lt;td&gt;oui&lt;/td&gt;&lt;td&gt;oui&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;1000,00&lt;/td&gt;&lt;td&gt;10&lt;/td&gt;&lt;td&gt;70&lt;/td&gt;&lt;td&gt;GIAC1-IMME&lt;/td&gt;
  
              &lt;/tr&gt;
  
          &lt;/table&gt;
  
      &lt;/div&gt;
  
  
  
  &lt;/div&gt;
  </code></pre>