I am not sure on what are you trying to do, but

alert($("#ulList .liEven:first").attr("class")); /* Returns Success*/

Maurício


  -----Mensagem Original----- 
  De: Dave 
  Para: jQuery (English) 
  Enviada em: terça-feira, 16 de junho de 2009 09:57
  Assunto: [jQuery] Get first element when there are multiple classes



  Hi

  How do you get the first element when the element got multiple
  classes?

  <ul id="ulList">
          <li class="liRow">11111</li>
          <li class="liRow liEven">22222</li>
          <li class="liRow">33333</li>
          <li class="liRow liEven">44444</li>
  </ul>
  <input id="btSave" type="button" value="Save" />

  $("#btSave").click(function(event) {
          alert($("#ulList .liRow:first").attr("class"));/* Success */
          alert($("#ulList .liRow .liEven:first").attr("class"));/* Hmm
  */
  });

  Cheers

Reply via email to