Apologies in advance... this seems so straightforward but it's as iff my append in the for loop acts as an html method and overwrites the inner html.
$(function () {
var wrapper = $('<div />', {
class: 'row'
}),
button = $('<div />', {
class: 'column'
}),
buttons = [];
for (var i = 0; i < 2; i++) {
var btn = (i % 2)? button.html(i + 1) : button.addClass('last').html(i + 1);
buttons.push(btn);
if (i % 2) {
console.log('buttons', buttons);
$('.container').append(wrapper.append(buttons));
console.log('wrapper', wrapper);
console.log('container', $('.container'));
buttons = [];
}
}
});