I have a div with id test
and through the foreach loop I am creating some inner divs inside the test div. So it becomes like this.
You can use
$('[id^=test-]')
and each()
this way for example :
$('[id^=test-]').each(function(){ var atId = this.id; // do something with it });