Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda