Estoy trabajando en algunos JS con JQuery. Estoy tratando de obtener algunos elementos de la lista y almacenarlos en una matriz. No puedo entender lo que estoy haciendo mal, el problema se explica en los comentarios del siguiente código.
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; } Entonces mi pregunta es ¿por qué $(this) es una matriz vacía?