I am struggling to retrieve an element's children and then access the children of each child element.
Even though I have attempted this code, I cannot figure out why it is not functioning correctly:
var myElement = $('.a-container');
var myChildren = myElement.children();
for(var i = 0; i < myChildren.length; i++) {
var myGrandChildren = myChildren[i].children();
}
Unfortunately, when I run this code, I encounter an error stating that myChildren[i].children()
is not a function.
Can someone please explain why this approach does not work for achieving my goal?