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

236
Vistas
if i click in body nothing change but if i clicked in image itself it changed why?

if i click in body nothing change but if i clicked in image itself it changed why?

let element = document.querySelector("img");
document.body.addEventListener("click", function(e) {
  element.src = "images/2.jpg";
})
<img src="x">

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

try to give the body a color using CSS. body by default takes the content height and 100% of the width. if you want to make the event happen when clicking on the screen you should apply the event on the HTML tag or give the body 100% width and height.

    body {
      width :100%; 
      height: 100%;
    } 
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