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

172
Vistas
Given an element, how to detect which "n" it is in an "nth of type"?

I know how to select the nth element of a certain type document.querySelectorAll('.myClass')[n],

but given an element myEl = document.querySelector('.myClass .myOtherClass'),

how do I then determine its place (its "n") in the array of elements selected by document.querySelectorAll('.myClass')?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

do this:

document.querySelectorAll(".myClass").indexOf(yourElement) // ==> your index

about 4 years ago · Juan Pablo Isaza Denunciar

0

U can try something like that:

Array.prototype.indexOf.call(document.querySelectorAll('.myclass'),myEl)
about 4 years ago · Juan Pablo Isaza 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