олдскул)
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8" />
<style type="text/css">
div {
border: 2px solid blue;
margin: 2px;
padding: 2px;
}
img{
border: #FF0000 1px dotted;
width: 50px;
height: 50px;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<img src="" />
<img src="" />
<img src="" />
<img src="" />
<img src="" />
<img src="" />
<img src="" />
<img src="" />
<script>
var parent = document.body,
imgs = [].slice.call(parent.getElementsByTagName('img'));
for(var i = 0, l = imgs.length, div; i < l; i++){
if(i%3 === 0) div = parent.appendChild(document.createElement('div'));
div.appendChild(imgs[i]);
}
</script>
</body>
</html>