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

165
Visualizações
div content on scrolled bottom html javascript

i want to ask about div content scroll listener (not page). so I have an html code where the appearance of the web design resembles a native application. what I want to do is how do I detect if the user has scrolled down the content div? not a page because my web page for him is only silent, but the one that moves in the div. my div code is something like this

<div class="product-list-item">
   //product card
   //product card
</div>

enter image description here

and when i scroll like this

enter image description here

I want to see other products using ajax when it reaches the bottom of the div, for now I still using the manual button to load other products.

I've used this code but it's not working.

<script>
$(window).scroll(function() {
      if($(window).scrollTop() == $(document).height() - $(window).height()) {
            // ajax call get data from server and append to the div
      }
  });
</script>

does anyone have a solution for this? Thank you in advance.

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

0

Assuming you have this:

<div class="product-list-item" id="target">
   //product card
   //product card
</div>

You can use this script to check if you reached your target div:

<script>
        $(window).scroll(function() {
            if ($(this).scrollTop()+$(this).height() >= $('#target').position().top) {
                console.log('Target Reached');
            }
        });
    </script>

You can use this approach to only execute the code once , once it has reached the target div

<script>
        let isReached = false;
        $(window).scroll(function() {
            if ($(this).scrollTop()+$(this).height() >= $('#ftr').position().top && isReached == false) {
                isReached = true;
                //ajax call
            }
        });
    </script>
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