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

175
Vistas
Click event is not working in html DOM innerTEXT

I want to make a truth or dare website where people can play truth or dare online but I've faced some problems.

Html Code

<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>

here is my js code

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)
})

but when I clicked the button it says Uncaught TypeError: games.innerText is not a function

now, what can I do?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

it says that games.innerText is not a function that takes a parameter. The right use of innerText method is:


games.innerText = truth;

same as innerHtml

take a look innerText docs from MDN

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