So I have a JSON feed that returns a list of job titles. I would like the split the parsed data so that they are split into nodes of 3. So for example, right now I am appending all the ones into HTML that looks like:
<div class="slide">
<div class="jobs-list">
<a href="#" class="job">Title 1</a>
<a href="#" class="job">Title 2</a>
<a href="#" class="job">Title 3</a>
<a href="#" class="job">Title 4</a>
<a href="#" class="job">Title 5</a>
</div>
</div>
I would like the output to look like:
<div class="slide slide1">
<div class="jobs-list">
<a href="#" class="job">Title 1</a>
<a href="#" class="job">Title 2</a>
<a href="#" class="job">Title 3</a>
</div>
</div>
<div class="slide slide2">
<div class="jobs-list">
<a href="#" class="job">Title 4</a>
<a href="#" class="job">Title 5</a>
</div>
</div>
Here is my current JS
$.get('sample-json/9.json', function (data) {
var data = $.parseJSON(data);
console.log(data);
if (data.result.length === 0) {
alert("No Data. Show Error Screen.");
} else {
count = 0;
count++;
$("#careers .slides").append('<div class="slide slide' + count + '"></div>');
$('.slide' + count).append('<div class="jobs-list"></div>');
$(data.result).each(function (i, d) {
$('.slide' + count).find(".jobs-list").append(
'<a class="job cf" href="#">'+ d.type + '</a>');
});
}
});
Any pointers on how I should go about doing this?