Link to home
Start Free TrialLog in
Avatar of clickclickbang
clickclickbang

asked on

Loop through all div elements on a page

Experts, I need to loop through all div elements on a page. The only problem is that I won't know which is the outer most element to begin the loop. I will also need to recursively loop through the divs to find child divs. Can anyone give me a quick example of how to go about this or a link?

Thanks much!
ASKER CERTIFIED SOLUTION
Avatar of Morcalavin
Morcalavin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what happens if there are five topmost divs, like this?

<body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>

Can you describe a bit more what you want?
Avatar of clickclickbang
clickclickbang

ASKER

Awesome, that is perfect!