Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

86
Visualizações
Getting incorrect offsetTop position even though i'm using correct syntax

I'm trying to get the offsetTop position shown in google chromes inspector when you output an element.

The exact measurement it shows for offsetTop is "2942" but when I try the following below, it shows many different numbers but none is equal to that number.

It's instead showing "924" which i'm not sure what it's relative to.

The DOM tree looks like this:

Parent DIV (absolute positioned)

Child DIV (positioned relative)

Element (positioned relative) (Showing 924 for offsetLeft instead of 2942 in inspector.

How can I get it to match the value of 2942 for offset instead of 924?

Code:

$('.draggable:not(.container, #pageBody, .boundingBox)').each(function(){
                allElmDistY.push($(this).offset().top);
                allElmDistY.push($(this).position().top);
                allElmDistY.push($(this)[0].offsetTop);

                console.log($(this)[0].offsetTop, $(this));
            })

I'm outputting the information inside the loop so I can look at it through the developer console as well as which element it's being refered to.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda