title: jquery: Change table row background color in a even tr
body: <p>I have the following code (part of) in a php file:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function() {
      $(".MyYable tr:even").addClass("alt");
      jQuery("table tr").click(function(){
         var row = jQuery(this);
         var hasClass = row.hasClass("highlight");
         jQuery("table tr").removeClass("highlight");
         if(!hasClass){
           row.addClass("highlight");
         }
      });
      });
  &lt;/script&gt;
  
  &lt;style type="text/css"&gt;
  
  .highlight{
  background-color:#00FF00;
  }
  tr.alt td {
  background:#CCCCCC;
  }
  tr.over td {
  background-color:#00FF00;   
  }
  &lt;/style&gt;
  
          &lt;table id="Tabela_lista_empresas" width="751"&gt;
            &lt;thead&gt;
            &lt;tr&gt;
              &lt;th width="300"&gt;&lt;strong&gt;Descrição&lt;/strong&gt;&lt;/th&gt;
              &lt;th width="100" align="center"&gt;&lt;strong&gt;Qtd&lt;/strong&gt;&lt;/th&gt;
              &lt;th width="100" align="center"&gt;&lt;strong&gt;Refª cliente&lt;/strong&gt;&lt;/th&gt;
            &lt;/tr&gt;
            &lt;/thead&gt;
  
            &lt;?php do {?&gt;
  
            &lt;tr &lt;?php echo $i++ % 2 ? 'class="odd"' : ''; ?&gt; onClick="get(&lt;?php echo $row_rs_listaequipamentos['id_equipamento']; ?&gt;, this)"&gt;
              &lt;td width="300"&gt;&lt;?php echo $row_rs_listaequipamentos['descricao_curta']; ?&gt;&lt;/td&gt;
              &lt;td width="100" align="center"&gt;&lt;?php echo $row_rs_listaequipamentos['quantidade']; ?&gt; &lt;?php echo $row_rs_listaequipamentos['unidades']; ?&gt;&lt;/td&gt;
              &lt;td width="100" align="center"&gt;&lt;?php echo $row_rs_listaequipamentos['referenciacliente']; ?&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;?php } while ($row_rs_listaequipamentos = mysql_fetch_assoc($rs_listaequipamentos)); ?&gt;
          &lt;/table&gt;
  </code></pre>
  
  <p>In my case, when I click in a odd row, it will change the class to "highlight", but if I click on a even row nothing happens.
  Any help is appreciated.
  Note: I'm trying to learn "by-my-self", so I'm not an expert in programming.
  Thanks</p>