【发布时间】:2022-01-01 08:09:09
【问题描述】:
我想做一个真心话大冒险网站,人们可以在线玩真心话大冒险,但我遇到了一些问题。
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>
这是我的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)
})
但是当我点击按钮时,它显示 Uncaught TypeError: games.innerText is not a function
现在,我该怎么办?
【问题讨论】:
标签: javascript html web