Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Each Function Inside a jQuery Each Function [closed]

Tags:

jquery

each

I can't figure out if this is possible, basically want to run an each function on every article and run another each function inside that each function on every li in that article, is this possible? I can post more details later.

like image 239
LookingLA Avatar asked Oct 21 '13 18:10

LookingLA


1 Answers

The jQuery $.each() function is just a loop. It iterates through the item that the selector returns. Since this is the case, if you select every UL on the page, then while viewing that UL item, you select all li items for that UL, then so on and all spans in each li. You can go on forever if the items are there. It doesn't matter, it is just a loop.

 $.each("ul", function(index, element)
 {
      var $this = $(this);
      var $items = $this.find("li");
      //now next loop
      $.each($items, function(n, e)
      {
          //this is each li in this ul
      });
 });
like image 71
Casey ScriptFu Pharr Avatar answered Nov 14 '22 23:11

Casey ScriptFu Pharr