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

188
Vistas
How to make a div clickable using javascript?

I want a parent div to be clickable through using javascript. Here is the code:

document.getElementById("box").addEventListener("click", function() {
  window.location.href = "https://example.com";
});
#box {
  width: 200px;
  height: 200px;
  background-color: red;
}
<div id="box">
  //something
</div>

But the script doesn't work. I've replaced the script by the following one, but still doesn't work:

document.querySelector("#ID").addEventListener("click", function() {
  window.location.href = "https://example.com";
}); 

so, where am I doing wrong?

about 4 years ago · Juan Pablo Isaza
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