Looping through div's in jQuery
<p>I have the following script:</p>

<pre><code>     $('#divs').children().each(
  function(){

   //Get Id's
   var id = $(this).attr('id').replace('id_','');
   alert(id);

  }
 );
</code></pre>

<p>With the markup of:</p>

<pre><code>      &lt;div id="divs"&gt;
     &lt;div id="item_1"&gt;
         &lt;div id="sub_1"&gt;
             ---
            &lt;/div&gt;
            &lt;input type="button" value="Submit"/&gt;
        &lt;/div&gt;

        &lt;div id="item_2"&gt;
             &lt;div id="sub_1"&gt;
                ---
             &lt;/div&gt;
             &lt;input type="button" value="Submit"/&gt;
        &lt;/div&gt;
  &lt;/div&gt;
</code></pre>

<p>Basically, it loops out twice for each id="item_" set... I just want it to count the item_1, item_2, etc. divs.  Not the sub_1, etc.</p>

<p>Any ideas how to fix this? Thank you!</p>
