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

131
Visualizações
Page pointing to previous id in same browser same tab

I have written a js scripts to point an id on document.ready function but when I used same other id in the url then it pointed to the previous id, My first point id is abc.com/#firstid and second is id abc.com/#secondid. while I am using it second id in the same browser same tab it pointed to first is i.e pointing to the section having id #firstid

 jQuery( document ).ready(function(e) {
           
          if (window.location.href.indexOf("/#") > -1) {
            var str = window.location.href;
            var spilt = str.split("/#");
            var url_id = spilt[1];
            console.log(url_id);
            jQuery('html, body').animate({ scrollTop: jQuery("."+url_id).offset().top-100 }, 100); 
            
           }  
           
        });


<div class="#firstid">
1
</div>
<div class="#secondid">
2    
</div>

after browse the url in browser abc.com/#firstid it points on 1 and while browse abc.com/#secondid it pointed on 2 but after then goes to 1 as page complete load

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