Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
Write all outerText to array

I am trying to write out all outerText values to an array.

This is based on a class selector

jQuery is usable my attempt is below syntax invalid e.g.

array =[];
  $( ".v-captiontext" ).each(function( index )
{
  array.push($( this ).outerText() )    
    );
});
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

var array = [];

$(".v-captiontext").each(function(index) {
  array.push($(this).outerText());   
});

is the correct syntax. Seems like you are not using any IDE. Start using one.

about 4 years ago · Juan Pablo Isaza Relatório

0

Firstly, the reason you have invalid syntax is because you have an extra ) in the code. If you format your code it makes it easier to spot mistakes like this.

With regard to your goal, outerText is the property of an Element object, not a jQuery object or a method. Call it on the this reference directly:

let array = [];
$(".v-captiontext").each(function() {
  array.push(this.outerText);
});

Also note that you can simplify this further by using map() instead of each():

let array = $(".v-captiontext").map((i, el) => el.outerText).get();
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda