 <p>You were very close. Here's your code, modified to search for children of <code>#items</code> which have an id that starts with <code>id_</code></p> <pre><code>$('#items *[id^=id_]').each(function(){ alert($(this).attr('id')); }); </code></pre>