[英]How do I build a jeopardy game using html table and javascript?
My goal is to develop an online jeopardy game website using HTML and Javascript.我的目标是使用 HTML 和 Javascript 开发一个在线危险游戏网站。 I am trying to link each table cell with wager amounts to a small popup window that asks a question.
我试图将每个表格单元格与下注金额链接到一个询问问题的小弹出窗口。
I have already created the background gameboard using an HTML table.我已经使用 HTML 表格创建了背景游戏板。
<body>
<table>
<tr>
<td colspan=5><h1>Biomedical Blazer!</h1> </td>
</tr>
<tr>
<td><h1> 1 </h1></td>
<td><h1> 2 </h1></td>
<td><h1> 3 </h1></td>
<td><h1> 4 </h1></td>
<td><h1> 5 </h1></td>
</tr>
<tr>
<td id="1cat500"><h1> $500 </h1></td>
<td id="2cat500"><h1> $500 </h1></td>
<td id="3cat500"><h1> $500 </h1></td>
<td id="4cat500"><h1> $500 </h1></td>
<td id="5cat500"><h1> $500 </h1></td>
</tr>
<tr>
<td id="1cat400"><h1> $400 </h1></td>
<td id="2cat400"><h1> $400 </h1></td>
<td id="3cat400"><h1> $400 </h1></td>
<td id="4cat400"><h1> $400 </h1></td>
<td id="5cat400"><h1> $400 </h1></td>
</tr>
<tr>
<td id="1cat300"><h1> $300 </h1></td>
<td id="2cat300"><h1> $300 </h1></td>
<td id="3cat300"><h1> $300 </h1></td>
<td id="4cat300"><h1> $300 </h1></td>
<td id="5cat300"><h1> $300 </h1></td>
</tr>
<tr>
<td id="1cat200"><h1> $200 </h1></td>
<td id="2cat200"><h1> $200 </h1></td>
<td id="3cat200"><h1> $200 </h1></td>
<td id="4cat200"><h1> $200 </h1></td>
<td id="5cat200"><h1> $200 </h1></td>
</tr>
<tr>
<td id="1cat100"><h1> $100 </h1></td>
<td id="2cat100"><h1> $100 </h1></td>
<td id="3cat100"><h1> $100 </h1></td>
<td id="4cat100"><h1> $100 </h1></td>
<td id="5cat100"><h1> $100 </h1></td>
</tr>
I am not able to link an onClick method on Javascript with the individual cell IDs.我无法将 Javascript 上的 onClick 方法与单个单元格 ID 链接起来。
const cell = document.querySelector('#1cat500');
cell.addEventListener('click', e => {
// stuff in here
});
Use Modal to pop up the window which will ask question.使用 Modal 弹出提问窗口。
Put the question in json file and utilize the fetch method of javascript which will read the json file and takes the question.将问题放在 json 文件中,并利用 javascript 的 fetch 方法读取 json 文件并获取问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.