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

103
Views
Works in the console but not in the editor

I am practicing JavaScript with a program that should change the image of a dice according to a random number. If I put this line in the console the images changes; it works.

document.querySelector("img.img1").setAttribute("src", "images/dice1.png");

but if I put it in the editor I get the following error message:

index.js:5 Uncaught TypeError: Cannot read properties of null (reading 'setAttribute') at index.js:5

Why?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I forgot differ the link of the js link file in the head. I put this line

<script src="index.js" charset="utf-8"></script>

only in the head of the html file. I should differ it or put it in the end of the body section.

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!