Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
190
rated 0 times [  197] [ 7]  / answers: 1 / hits: 21232  / 14 Years ago, sat, may 29, 2010, 12:00:00

I want to access a simple button in an unknown nested level of a container.



Using container.children('button') allows me to access buttons in the first level, I.E.:



<div>
<button>test</button>
</div>


Trying to use the same with the following construct:



<div>
<div>
<button>test</button>
</div>
</div>


Fails, because the button is not a direct children. I could use element.children().children('button') but the depth of the button can change and this feels too strange.



I can also write my own function to iterate though all children to find what I need, but I guess jQuery does already have selectors for this.



So the question is:



How can I access children in an unknown depth using jQuery selectors?


More From » jquery

 Answers
16

How about



container.find('button');

[#96646] Thursday, May 27, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kinsley

Total Points: 352
Total Questions: 84
Total Answers: 94

Location: Denmark
Member since Tue, Jul 19, 2022
2 Years ago
;