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

158
Vistas
JQuery each function $(this) always undefined

I am working on some JS with JQuery. I'm trying to get some list items and store them into an array. I can't understand what I'm doing wrong, the problem is explained in the commentaries of the following code.

function getListItems() {
        let items = [];
        const $items = $listElement.children('li');
        $items.each(index => {
            console.log($(this)); // shows an empty array, according to JQuery doc it should show the DOM element
            items.push($($items.get(index)).html()); // Works, but what it would be cleaner to do this : items.push($(this).html())
//... which does not work
        });
        return items;
    }

So my question is why $(this) is an empty array ?

about 4 years ago · Juan Pablo Isaza
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