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

108
Visualizações
how to scroll a div to the desired text by clicking it inside another div

In the example below please click on abc from left side.
I need the right side to scroll so the first instance of abc is visible
And - if possible - the right abc should be marked
On my site - on click - the right side is scrolled a few pixels - Whatever is clicked on left side - but not to the desired text
In the snippet here - on click - there is no a scroll at all

$('.atitle').on('click', function(){
    let a = $(this).text();
    $('#bins').scrollTop($("*:contains(" + a + "):first").offset().top);
});
html{
overflow:hidden;
}
.grida{
display:grid;
grid-template-columns:auto 1fr;
}
.gridaa, .bins{
height:99px;
overflow-y:scroll;
}
.bins{
white-space:pre-wrap;
}
.atitle{
cursor:pointer;
padding:0 14px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class='grida'>
<div class='gridaa'>
<div class='atitle'>lorem</div>
<div class='atitle'>ipsum</div>
<div class='atitle'>abc</div>
<div class='atitle'>dolor</div>
<div class='atitle'>sit</div>
<div class='atitle'>amet</div>
<div class='atitle'>sky</div>
<div class='atitle'>earth</div>
<div class='atitle'>sun</div>
<div class='atitle'>moon</div>
</div>
<div class='gridab'>
<div class='bins' id='bins'>
sky
moon
earth
sun
sit
amet
ipsum
abc
lorem
sit
dolor
</div>
</div>
</div>

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