Here is a FIDDLE
HTML
<div class="colorboxElements">
<a href="#box">click here!</a>
<div id="box" class="box">here is the content!</div>
</div>
JS
$('.colorboxElements a').each(function (index) {
$(this).attr("href", "#box" + index);
$(this).siblings('.box').attr("id", "box" + index);
});
$(".colorboxElements a").colorbox({
rel: 'colorboxElements',
inline: true,
transition: "none",
width: "75%",
height: "auto"
});