JSFiddle - React, Tailwind, and code Playground
HTML
<div id="projectList"></div>
CSS
.row-fluid {
border-color: black;
background: red;
}
JavaScript
var i = 0;
var json = {
projects: [{
title: "t1",
description: "d1"
}, {
title: "t2",
description: "d2"
}, {
title: "t3",
description: "d3 "
}, {
title: "t4 ",
description: "d4 "
}, {
title: "t5 ",
description: " d5 "
}]
};
function myjson(json) {
$.each(json.projects, function (index, data) {
//some stuff to find and filter my data
$('<div/>', {
"id": index,
"class": "span4",
html: '<h3>' + data.title + '</h3>' + data.description
}).appendTo('#projectList');
});
}
function test() {
myjson(json);
var divs = $('#projectList > div');
for (var i = 0; i < divs.length; i += 3) {
divs.slice(i, i + 3).wrapAll('<div class="row-fluid "></div>');
}
}
test();