function rowBreak() {
$('.col-flex:hidden').each(function (i, e) {
if (((i + 1) % 4 == 0) && ($(this).siblings().length != 3)) {
var x = $('.col-flex:visible:gt(' + i + ')');
$('
').append(x).insertAfter($(this).closest('div.row'));
}
});
}
$(function() {
rowBreak();
$('#search').on('keyup', function() {
$('.col-flex').hide();
var s = this.value.toLowerCase();
$('.col-flex').filter(function() {
return $(this).find('h4').text().toLowerCase().indexOf(s) > -1;
}).show();
rowBreak();
});
});
body {
padding: 10px;
}