Something like this will work. Using length
of next()
to see if it exists, otherwise start at beginning
$(".next").click(function() {
var $current=$("#captions-container .caption:visible").hide();
var $next = $current.next().length ? $current.next() : $current.siblings('.first');
$next.show();
});