lundi 22 novembre 2021

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?




Aucun commentaire:

Enregistrer un commentaire