I have the following script:
$('#divs').children().each(
function(){
//Get Id's
var id = $(this).attr('id').replace('id_','');
alert(id);
}
);
With the markup of:
<div id="divs">
<div id="item_1">
<div id="sub_1">
---
</div>
<input type="button" value="Submit"/>
</div>
<div id="item_2">
<div id="sub_1">
---
</div>
<input type="button" value="Submit"/>
</div>
</div>
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.
Any ideas how to fix this? Thank you!
Thanks guys, I ended up going with:
$(‘#divs’).children(/[id_]/).each