The .next() gets next sibling, if you have html structure:
<div id=id1></div>
<div id=id2></div>
<div id=id3></div>
<div id=id4></div>
Then, you can walk over each of these divs like this:
$('#id1').click(function(){
// get next that id2
$(this).next()..........
});
Edit
Give your divs class also:
<div id=id1 class="test"></div>
<div id=id2 class="test"></div>
<div id=id3 class="test"></div>
<div id=id4 class="test"></div>
Now with JQuery you can loop each of them like this:
var i=0;
$('.test').each(function(){
// get next and so on
$('#id'+i).next()..........
i++;
});