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

123
Vistas
Links with onclick keep on giving me errors

I am learning how to make links work with JS and after trying a few different things I managed to make it work but I geta n error on the console and I'd like to understand why.

const card = document.getElementById("card2");
const flipButton = (document.querySelector(".side-two").onclick =
  function flip() {
    if (card.className == "card2_back") card.className = "card2_front";
    else card.className = "card2_back";
  });

const goToQuiz = (document.querySelector(".start-quiz").onclick =
  function goToQuiz() {
    location.href = "./quiz.html";
  });

const goToQuiz2 = (document.querySelector(".tutorial-start-quiz").onclick =
  function goToQuiz() {
    location.href = "./quiz.html";
  });

This works but I get an error on the target page's console

app.js:4 Uncaught TypeError: Cannot set properties of null (setting `enter code here`'onclick')
    at app.js:4:65

I have tried different things like

goToQuiz.addEventListener("click", (e) => {
  onclick = goToQuiz() {
    location.href = "./quiz.html";
  };
});

goToQuiz2.addEventListener("click", (e) => {
  onclick = function () {
    location.href = "./quiz.html";
  };
});

I'd appreciate the help!

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