Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!