简体   繁体   English

如何使用 html table 和 javascript 构建危险游戏?

[英]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.

相关问题 如何使用 Javascript 数组构建 HTML 表 - How do I build an HTML table using Javascript array 如何在 javascript html 游戏中使文本更大? - How do I make text bigger in a javascript html game? html表,用Javascript做小冒险游戏 - html table, using Javascript for a little adventure game 如何使用 javascript 创建猜数字游戏并做出反应? - How do I create a number guessing game using javascript and react? 我需要使用带有奇怪的 Google 电子表格链接的 Javascript 创建一个 HTML 表格。 我该怎么做呢? - I need to create an HTML table using Javascript with a weird Google Spreadsheet link. How do I do this? 尝试使用前端语言即 html、css 和 javascript 构建骰子游戏 - Trying to build a dice game using front end languages i.e html,css and javascript 我需要仅使用 javascript 更新 html 表中的特定单元格,我如何定位此单元格? - I need to update a specific cell in an html table using only javascript, how do i target this cell? 如何使用JavaScript写入html? - How do I write into the html using JavaScript? 我如何制作一个使用 javascript 提示创建 html 表格的网站? - How do i make a website that creates a html table using javascript prompts? 如何使用 JavaScript 对 HTML 表中的价格列求和? - How do I sum the price column from HTML table using JavaScript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM