const $containers = $('.wrapper .inner');
const offsetTopsArray = [];
$containers.each(function(idx,el){
offsetTopsArray[idx] = el.position().top;
offsetTopsArray[idx].isLineBreak = (idx === 0 ? true : false);
if(idx > 0) {
if(offsetTopsArray[idx] > offsetTopsArray[idx-1]) {
// it's on a new line
offsetTopsArray[idx].isLineBreak = true;
}
}
});
You can now iterate through the array, using the index to check for .isLineBreak property being true and perform necessary actions with the div.
UPDATE:
An illustration of how this could be implemented:
const containerCount = $containers.length;
for(let i=0; i<containerCount; i++) {
if(true === offsetTopsArray[i].isLineBreak) {
$containers.eq(i).addClass('line-break-marker');
}
}
.line-break-marker {
-webkit-box-shadow:0 0 10px black;
-khtml-box-shadow:0 0 10px black;
-moz-box-shadow:0 0 10px black;
-o-box-shadow:0 0 10px black;
-ms-filter:"progid:DXImageTransform.Microsoft.Shadow(Strength=2, Direction=0, Color='#000000')";
filter:progid:DXImageTransform.Microsoft.Shadow(Strength=2, Direction=0, Color:'#000000');
box-shadow:0 0 10px black;
zoom:1;
}