Hello. In my code there is an $ bricks array, each element that falls into this array has a different top and positon: absolute. How can I determine the top element in an array. I tried :

function() { for (var i = 0; i < $bricks.length; i++) { $bricks[i].offset().top) } } 

But it does not work. Please tell me the way out. I will be glad to any advice.

  • Why is there a closing bracket? Why braces? Sorry, but what kind of addiction? - Crasher

1 answer 1

  for( var i = 0; i < $bricks.length; i++ ){ var offset = $bricks.eq(i).offset(); if( offset != null ){ console.log(offset.top); } } // или $bricks.each(function (){ var offset = $(this).offset(); if( offset != null ){ console.log(offset.top); } }); 
  • Great, everything works fine. Thank you very much))) - Kuzyo pm