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

226
Visualizações
In Javascript console when console.log(a variable) if reloading the page change the info it shows

I have this code

<div class="buttons">
    <button>Press 1</button>
    <button>Press 2</button>
    <button>Press 3</button>
</div>
<script>
    const buttonContainer = document.querySelector('.buttons');
    console.log('buttonContainer', buttonContainer);
  
    buttonContainer.addEventListener('click', event => {
        console.log(event.target);
    })
</script>

when open the console for the first time, it shows this: (arrow)div.buttons

where I can see the properties and methods of the variable.

When reloading the page, it changes to this: <div class: "buttons">...

Any one could explain to me why it happens? and how i can toggle between 2 of those options, I see very helpfull to see the list of the properties and methos of my variable when needed.

Thanks :)

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

0

its because that script is downloaded in parallel to parsing the page, and the rendering tree might not be parsed yet. to fix this, add defer prop to your script. That should make it execute after the parsing.

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