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

117
Vistas
Why Aren't My Buttons Working In Extensions

I have been trying to code a snake game extension for fun and I have run into some problems, programmed buttons on my extension aren't working. I can't click them and haven't found a tutorial that can help me. I'm not sure if I'm just stupid and buttons aren't and haven't been able to be used in extensions but, if they are then my code must be the problem.

This is my HTML code if it helps:

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="/css/button.css">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Google Snake</title>
    <style>
        body{
            margin: 0px;
            padding: 0px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;

        }
        canvas{
            box-shadow: black 20px 10px 50px;
        }
    </style>
  </head>
  <body>
    <h1>Snake</h1>
    
    <button onclick="doSomething()">Restart</button>

    <p id="test">Hello</p>

    <script>
        function doSomething(){
            document.getElementById("test").innerHTML = "Goodbye";
        }
    </script>

    <script src="/js/index.js"></script>
    <canvas id="game" width="400" height="400"></canvas>
  </body>
</html>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I tried your code and your button worked. By not working if you mean that you can not change goodbye back to hello you need to write another function to do it vice versa. I changed your script take a look at it. It is one way of doing it, of course if this was your question.

function doSomething() {
  if (document.querySelector("p").innerHTML === "Hello") {
    document.querySelector("p").innerHTML = "Goodbye";
  } else {
    document.querySelector("p").innerHTML = "Hello";
  }
}
body {
  margin: 0px;
  padding: 0px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

canvas {
  box-shadow: black 20px 10px 50px;
}

</style
<!DOCTYPE html>
<html>

<head>
  <link rel="stylesheet" href="/css/button.css">
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Google Snake</title>
</head>

<body>
  <h1>Snake</h1>

  <button onclick="doSomething()">Restart</button>

  <p>Hello</p>
  <script src="/js/index.js"></script>
  <canvas id="game" width="400" height="400"></canvas>
</body>

</html>

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