How to get top offset of element in jQuery?

Console logthe second day I try to calculate top px and it doesn’t work all the time

I tried this, but nothing happens and at the same time it finds the desired element

const lastElement = $(Section).find('.new-element-wrapper').last().get(0);

const lastElementTop = $(lastElement).offset().top + $(lastElement).outerHeight() + 5;

console.log(lastElementTop);

console.log(lastElement);