I have some problems with looping and breaking.
I have an array n when i reach 10th element i have to do smth. For example:
$.each(videoDataList,function(k){
html = ''
if(k % 10 == 0){
html += (k == 0 ? "<ul>" : "</ul><ul>");
}
html += '<li class="item">'
html += '<a href="#" id="vl_'+(k+1)+'">'
html += '<span class="score_journalist" id="num_'+videoDataList[k].score_journalist+'">'+videoDataList[k].score_journalist+'</span>'
html += '<img src="/files/preview/s/'+videoDataList[k].video_id+'.jpg" alt="" />'
html += '<span class="rating clearfloat">'
html += '<span class="votes"><span class="title">рейтинг:</span> <span class="count">'+videoDataList[k].score_user+'</span></span>'
html += '</span>'
html += '<span class="filter"></span>'
html += '</a>'
html += '<img src="/files/preview/b/'+videoDataList[k].video_id+'.jpg" alt="" class="big"/>'
html += '</li>'
if(k == videoDataList.length){
html += "</ul>";
}
$(html).appendTo('#videoLists ul.list')
})
i want to have 10 elements LI and put them into UL. then i want to loop my array from 11th element till 21th element and again LI from 11 to 21 i want to put in another UL.
Is it possible?
It’s easy with the modulo operator: