Q:

jQuery loop though two levels of elements

I have some html that looks like this:
<div class="block">
    <div id="item1"></div>
    <div id="item2"></div>
</div>

<div class="block">
    <div id="item3"></div>
</div>

I'm trying to check to see if my div will contain a specific element. I need to loop though each block, then get each item. 
What I've got so far
    $('.block:has(div)').each(function() {
            // do something with the block
    });

Which is great, because it will return all the blocks that have items in them. But I need something along the lines of
    $('.block:has(div)').each(function() {
             $('current place in loop' + li).each(function() {
                    // do something with each item element, before the block loop has finished
             });
    });

Any ideas?

A:

I hope you mean this:
$('.block').each(function(){
    $(this).find('div').each(function(){
        //do your stuff
    });
});

A:

I'm not 100% sure if this answers what you are asking, but wouldn't the following work:
$('.block:has(div)').each(function() {
  $(this).children('div').each(function() {
    // do something with each item element, before the block loop has finished
  });
});

