views:

40

answers:

2

Hi I have next

ul
 li1
 li2
 ul3
  li3.1
  li3.2
  ul3.3
   ul3.3.1
   ul3.3.2
 li4
 li5

and I must check all items in ul3 I can't be sure if there is only two or three or more lists

+3  A: 

Use the each() like this:

$('ul li').each(function(){
  // your code.....
});

This will loop through the ul children at any nested level.

Update:

and I must check all items in ul3 I can't be sure if there is only two or three or more lists

Try this in that case:

$('ul:eq(2) li').each(function(){
  // your code.....
});

This will start from third ul and find its children at any nested level.

Sarfraz
+3  A: 
Pointy
+1 plain JavaScript, since native loops are always faster then JQuery.
Anders