//loop through each selected and now find the new top based on the maxY and apply it to each
$(“.ui-selected”)
.each(
function()
{
var h=$(this).height();
var newTop = maxY-h;
if (newTop>=0) $(this).css({top:newTop});
}
);

I am using two loops, first is to get the bottom Y position and then the second loop to apply the bottom y to each Div. There is a way in jQuery using command chaining but I just kept them two separate for easy reading.