I couldn't find any solution that would suit for me regarding this question, so excuse me if duplicating.
I want to go through all .children() items and if some of those items meet condition I want to save those items in one array. Here's the code to show exactly what I mean:
var items = [],
allitems = $('.iconImg').children(),
obj;
// console.log(allitems);
$('#next4').on('click', function(e){
e.preventDefault();
for(var i=0; i<allitems.length; i++){
var currItem = $(allitems[i]).attr('id'),
currItemPosLeft = parseInt($('#'+currItem).css('left')),
itemOffset = getOffset('#'+currItem),
items = [],
arrToSend = [];
// console.log(currItem, '=>', currItemPosLeft);
if(currItemPosLeft >= 405){
obj = {
obId: currItem,
obPos: itemOffset
}
items.push(obj);
console.log(items);
}
}
This code gives me separately number of arrays of objects that met condition, but what I would like is one array to store these objects.
How can I do this?
Thanks