Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

423
Vistas
How to get the eq() value?

Is this possible? For me to get the eq() value? For example, if I click the li:eq(2), var x will become 2. Here's the code.

$('#numbers ul li').click(function(){
  x=$(this).eq().val();
  alert(x);
});
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

The .index()what is this? method will do it.

$('#numbers ul li').click(function() {
  var self   = $(this),
      index  = self.index(),
      text   = self.text();

  alert(text + ' ' + index);
});

Demo: http://www.jsfiddle.net/Y2aDP/

over 4 years ago · Santiago Trujillo Denunciar

0

The answer above is wrong. Index provides a relative value with respect to its siblings. Hence, the value is expected to change.

It should be something like

$('.someClass').click(function(){
    var that_ = this;
    // your logic for this function
    ....
    ....
    var currentIndex = $('.someClass').index(_that);
});
over 4 years ago · Santiago Trujillo Denunciar

0

eq<> index:

scount=$(selector).length;
for(i=0; i<scount; i++){
    $("selector:eq("+i+")").attr("eq",i);
}
$("selector").click(function(){
    alert($(this).attr("eq"));
});
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda