<!DOCTYPE HTML>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
</head>
<body>
<div class="elements">
<div class="n1">...</div>
<div class="n2">...</div>
<div class="n3">...</div>
<div class="n4">...</div>
<div class="n5">...</div>
<div class="n6">...</div>
<div class="n7">...</div>
<div class="n8">...</div>
<div class="n9">...</div>
<div class="n10">...</div>
</div>
<script>
var $c = $('.elements');
while($c.children('div:not(.wrap)').length)
$c.children('div:not(.wrap):lt(5)').wrapAll('<div class="wrap">');
</script>
</body>
</html>