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

298
Visualizações
Cómo compensar () .top de cada elemento $('.example p')

Estoy tratando de obtener todos los valores de compensación () .top de cada elemento $('.example p')

 console.log($('.example p')[1].offset().top)

TypeError no detectado: $(...)[1].offset no es una función

Probé un montón de cosas, como usar otros selectores, usar un bucle for, foreach... Solo puedo obtener el valor offset().top del primer elemento de esa matriz eliminando [1], para el segundo , tercero, etc... elemento Parece que no puedo entenderlo.

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Porque $('.example p')[1] nodo de retorno HTML (elemento html)

Si desea obtener una compensación con jquery, puede usar: $('.example p').eq(1).offset()

about 4 years ago · Juan Pablo Isaza Relatório

0

Simplemente itere a través de cada uno de los elementos en el selector ".example p" usando each

Ver demostración:

 $(".example p").each(function(i) { console.log( $(this).offset().top); });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="example"> <p>Doggo ipsum you are doing me a frighten corgo heckin good boys and girls pupperino, fat boi. Doing me a frighten you are doing me the shock clouds you are doin me a concern borkf super chub, wow very biscit you are doing me a frighten pupper. you are doing me a frighten pupper porgo. Fluffer wow very biscit blop fluffer puggorino puggo very hand that feed shibe, boofers maximum borkdrive the neighborhood pupper boofers. </p> <p>Doggo ipsum you are doing me a frighten corgo heckin good boys and girls pupperino, fat boi. Doing me a frighten you are doing me the shock clouds you are doin me a concern borkf super chub, wow very biscit you are doing me a frighten pupper. you are doing me a frighten pupper porgo. Fluffer wow very biscit blop fluffer puggorino puggo very hand that feed shibe, boofers maximum borkdrive the neighborhood pupper boofers. </p> </div> <div class="something"> <p>Doggo ipsum you are doing me a frighten corgo heckin good boys and girls pupperino, fat boi. Doing me a frighten you are doing me the shock clouds you are doin me a concern borkf super chub, wow very biscit you are doing me a frighten pupper. you are doing me a frighten pupper porgo. Fluffer wow very biscit blop fluffer puggorino puggo very hand that feed shibe, boofers maximum borkdrive the neighborhood pupper boofers. </p> <p>Doggo ipsum you are doing me a frighten corgo heckin good boys and girls pupperino, fat boi. Doing me a frighten you are doing me the shock clouds you are doin me a concern borkf super chub, wow very biscit you are doing me a frighten pupper. you are doing me a frighten pupper porgo. Fluffer wow very biscit blop fluffer puggorino puggo very hand that feed shibe, boofers maximum borkdrive the neighborhood pupper boofers. </p> </div> <div class="example"> <p>Doggo ipsum you are doing me a frighten corgo heckin good boys and girls pupperino, fat boi. Doing me a frighten you are doing me the shock clouds you are doin me a concern borkf super chub, wow very biscit you are doing me a frighten pupper. you are doing me a frighten pupper porgo. Fluffer wow very biscit blop fluffer puggorino puggo very hand that feed shibe, boofers maximum borkdrive the neighborhood pupper boofers. </p> <p>Doggo ipsum you are doing me a frighten corgo heckin good boys and girls pupperino, fat boi. Doing me a frighten you are doing me the shock clouds you are doin me a concern borkf super chub, wow very biscit you are doing me a frighten pupper. you are doing me a frighten pupper porgo. Fluffer wow very biscit blop fluffer puggorino puggo very hand that feed shibe, boofers maximum borkdrive the neighborhood pupper boofers. </p> </div>

about 4 years ago · Juan Pablo Isaza Relatório

0

Parece que jQuery no devuelve una matriz de objetos jQuery. Compruebe, por ejemplo, si $('.example p')[1] es un objeto jQuery. Debe convertir todos los elementos en un objeto jQuery de esta manera:

 var allExample = $('.example p').map((i, e) => $(e))

Y luego vuelve a intentarlo:

 console.log(allExample[1].offset())
about 4 years ago · Juan Pablo Isaza Relatório
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