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

172
Views
El evento de clic no funciona en html DOM innerTEXT

Quiero hacer un sitio web de verdad o reto donde la gente pueda jugar verdad o reto en línea, pero me he enfrentado a algunos problemas.

Código HTML

 <button id="truth"> +t </button> <div><p id="game">+t for English Truth, +d For English Dare, +tb For Bangla Truth, +db for Bangla Dare</p></div>

aquí está mi código js

 const t = [ "If you could be invisible, what is the first thing you would do?", "What is a secret you kept from your parents?", "What is the most embarrassing music you listen to?", "What is one thing you wish you could change about yourself?", "Who is your secret crush?", ]; document.getElementById('truth').addEventListener('click', function(){ const truth = t[Math.floor(Math.random() * t.length)]; const games = document.getElementById('game'); console.log(truth) games.innerText(truth) })

pero cuando hice clic en el botón dice Uncaught TypeError: games.innerText no es una función

¿Ahora que puedo hacer?

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

0

dice que games.innerText no es una función que toma un parámetro. El uso correcto del método innerText es:

 games.innerText = truth;

igual que HTML interno

echa un vistazo a los documentos de texto interno de MDN

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!