klifort,
var quality = 27;
function portfolioBlock() {
var divs = $(".ih-item");
for(var i = 0; i < divs.length; i+=quality) {
divs.slice(i, i+quality).wrapAll("<div class='new1'></div>");
}
var newBl = $(".new1");
var new1 = new Array;
newBl.each( function( index, el) {
blockPort(el);
});
console.log(newBl);
};
function blockPort(el) {
var arrDiv = $('.ih-item', el);
arrDiv[0].classList.add("first");
arrDiv[14].classList.add("second");
arrDiv[26].classList.add("next");
console.log(arrDiv);
}