Answers

//find all the 'first' .row by checking the previous is not a .row
$('.row').prev(':not(.row)').next().each(function() {
//wrap all next elements until you find something not a div
$(this).nextUntil(':not(div)').addBack().wrapAll($("<div></div>", {
class: 'wrapper'
}));
});