Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

307
Views
¡Mi función onclick no funciona! ¿Qué estoy haciendo mal?

He estado tratando de escribir un programa de ajedrez con HTML, CSS y Javascript. Parece que no puedo obtener la función onclick para que funcione el botón "JUGAR COMO BLANCO". Revisé mi sintaxis en la parte de Javascript y creo que me parece bien. ¿Hay algo que esté haciendo mal con el código?

Aquí está el código:

 let info = document.getElementById("info"); function playAsWhite() { info.innerHTML = "the message I want to output"; }
 <h1 id="info">Playing as White:</h1> <h1>Best move:</h1> <p>NaN</p> <input type="text" placeholder="Your input:" id="inputId1"> <button onclick="player1Turn()">Enter</button> <input type="text" placeholder="Enemy input:" id="inputId2"> <button onclick="player2Turn()">Enter</button> <div class="functions"> <button onclick="playAsWhite()">PLAY AS WHITE</button> <button onclick="playAsBlack()">PLAY AS BLACK</button> <button onclick="reset()">RESET</button> </div>

He definido el archivo fuente ("main.js") correctamente y el script se carga al final del body .

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Su código es correcto Debería ser "onclick". Pero no se accede correctamente a su archivo javascript en html.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!