Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!