<div class="works blocks">
<div class="worksFastFood hide">
<div class="work-wrapper closed w1" style="width: 316.6px;">
<img data-video="Hiqu6-g523yM" data-alt-src="img/works/preview/Hiqu6-g53yM_h.jpg" src="img/works/preview/Hiqu6-g53yM.jpg" title="" alt="">
<h4>Digital_1</h4>
</div>
<div class="work-wrapper closed w2" style="width: 316.6px;">
<img data-video="r3-K4vv2R2e6E" data-alt-src="img/works/preview/r3-K4vvRe6E_h.jpg" src="img/works/preview/r3-K4vvRe6E.jpg" title="" alt="">
<h4>Digital_2</h4>
</div>
<div class="work-wrapper closed w1" style="width: 316.6px;">
</div>
<div class="clearfix"></div>
</div>
<div class="worksFitness hide">
<div class="work-wrapper closed w1" style="width: 316.6px;">
<img data-video="np_IEdf22z0I" data-alt-src="img/works/preview/np_IEdf2z0I_h.jpg" src="img/works/preview/np_IEdf2z0I.jpg" title="" alt="">
<h4>Digital_3</h4>
</div>
<div class="work-wrapper closed w1" style="width: 316.6px;">
<img data-video="1Rmzl2KpZTaY" data-alt-src="img/works/preview/1RmzlKpZTaY_h.jpg" src="img/works/preview/1RmzlKpZTaY.jpg" title="" alt="">
<h4>Digital_4</h4>
</div>
<div class="clearfix"></div>
</div>
</div>
А и з того кода что у меня получаеться во такая Разметка:
<code>
<div class="works blocks">
<div class="worksFastFood" style="float: left; height: auto;" hide"=""><div class="work-wrapper closed w2"><img data-video="r3-K4vvRe6E" src="/Kvinto/img/works/preview/r3-K4vvRe6E.jpg" data-alt-src="r3-K4vvRe6E.jpg title=" "="" alt=""><h3>Digital <br> </h3></div></div>
<div class="worksFastFood" style="float: left; height: auto;" hide"=""><div class="work-wrapper closed w2" style="width: 316.6px; background-color: rgb(33, 33, 33);"><img data-video="r3-K4vvRe6E" src="/Kvinto/img/works/preview/r3-K4vvRe6E.jpg" data-alt-src="r3-K4vvRe6E.jpg title=" "="" alt=""><h3>Digital <br> )</h3></div></div>
<div class="worksFitness" style="float: left; height: auto;" hide"=""><div class="work-wrapper closed w1" style="width: 316.6px; background-color: rgb(107, 32, 161);"><img data-video="np_IEdf2z0I" src="/Kvinto/img/works/preview/np_IEdf2z0I.jpg" data-alt-src="np_IEdf2z0I.jpg title=" "="" alt=""><h3>Digital <br> </h3></div></div>
<div class="worksFitness" style="float: left; height: auto;" hide"=""><div class="work-wrapper closed w1" style="width: 316.6px; background-color: rgb(107, 32, 161);"><img data-video="np_IEdf2z0I" src="/Kvinto/img/works/preview/np_IEdf2z0I.jpg" data-alt-src="np_IEdf2z0I.jpg title=" "="" alt=""><h3>Digital <br> </h3></div></div>
</div>
Вот сам код :
function renderWorked(itemsi) {
$('#cases').append('<div class="works block" > </div>'); // создаём див в который будет добавляться информация с джсон
var containered = $('.block'),
html = [],
i, item; // сюда должно добавлять
console.log(containered)
for (i = 0; i < itemsi.length; i++) {
item = itemsi[i];
var inter = item['Category'];
if ($(".FastFood, Azk,Fitness")) {
//if(inter === item['Category']){html.push('<div class="clearfix"></div>'); }
// $(".Food:last").after("<div class='clearfix'></div>");
console.log(inter);
html.push('<div class="works' + item['Category'] + '"' + 'style="float: left"' + 'hide">');
html.push('<div class="work-wrapper closed w' + item['Wraper'] + '">');
html.push('<img data-video="' + item['data-video'] + '" src="/Kvinto/img/works/preview/' + item['image-data'] + 'data-alt-src="' + item['data-alt-src'] + '.jpg title="" alt="" >');
html.push('<h3>' + item['title'] + '</h3>');
html.push('</div>');
}
html.push('</div>');
containered.html(html.join(''));
// html.push('<div class="clearfix"></div>');
}
}
var workItemsed = [
{
'Wraper': '2',
'Category': 'FastFood',
'data-video': 'r3-K4v2vRe6E',
'data-alt-src': 'r3-K42vvRe6E',
'image-data': 'r3-K4vvR2e6E.jpg"',
'title': 'Digital <br> digital'
}, {
'Wraper': '1',
'Category': 'FastFood',
'data-video': 'szor3Tr2gxm4',
'data-alt-src': 'szor23Trgxm4',
'image-data': 'szor3T2rgxm4.jpg"',
'title': 'Digital <br> Digital'
}, {
'Wraper': '2',
'Category': 'FastFood',
'data-video': '67-igPt2oM28',
'data-alt-src': '67-ig2PtoM28',
'image-data': '67-igP2toM28.jpg"',
'title': 'Digital <br> Digital'
},
{
'Wraper': '1',
'Category': 'Fitness',
'data-video': 'np_IEdf2z0I',
'data-alt-src': 'np_IE2df2z0I',
'image-data': 'np_IEdf22z0I.jpg"',
'title': 'Digital <br> Digital'
}, {
'Wraper': '1',
'Category': 'Fitness',
'data-video': '1RmzlK2pZTaY',
'data-alt-src': '1Rmzl2KpZTaY',
'image-data': '1RmzlKpZ2TaY.jpg"',
'title': 'Digital <br> Digital'
}, {
'Wraper': '1',
'Category': 'Fitness',
'data-video': 'yvfulPey2N94',
'data-alt-src': 'yvfulPeyN294',
'image-data': 'yvfulPe2yN94.jpg"',
'title': 'Digital <br> Концепт - Digital'
}
];
renderWorked(workItemsed);
$('#cases').append('<div class="clearfix"></div>');
$("#cases Azk:last").append('<div class="clearfix"></div>')
$('.FastFood').css('float, left');
});
Тоесть нужно чтоб например <code> <div class="worksFastFood"> </div> недублировался , а в него записывались <div class="work-wrapper closed w> Которые соотвецтвовалиб нужной категории.
</code>