Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery select DOM elements and access inner elements

I'm trying to make small script. I have main div that has 300 inner divs and I access them by:

$("#items").find(".item").each(function(index,ele){
    console.log(ele);
})

So it logs me all the inner divs. Now i want to access labels and read their inner html of these found divs.

How i can do that? Tried to mess with ele.label & ele.$("label"), but it doesn't work.

like image 287
Jan Kowalski Avatar asked Aug 17 '26 08:08

Jan Kowalski


1 Answers

You need to use .find or .children to find children/nested elements.

$(ele).children('label') // takes just direct children
$(ele).find('label') // take all nested labels
like image 123
pavel Avatar answered Aug 19 '26 23:08

pavel