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

104
Views
Javascript how to loop child element of children

I want to read an element's children and for each of the children, read their children.

I have done this but do not understand why it does not work:

var myElement = $('.a-container');
var myChildren = myElement.children();

for(var i = 0; i < myChildren.length; i++) {
     var myGrandChildren = myChildren[i].children();
}

The error I get is myChildren[i].children() is not a function.

Is this not how to achieve what I'm trying to do?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to select the element inside the loop:

myGrandChildren = $(myChildren[i]).children();

Although in this case, jQuery.eq is more suitable:

myGrandChildren = myChildren.eq(i).children();
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!