0
我不知道爲什麼,但是我的onLoad函數激活了所有我的函數,而沒有實際單擊按鈕。提前致謝。我似乎也有麻煩把JavaScript反引號。因此,JavaScript是在的jsfiddleJavascript:onLoad函數無意中激活了我的EventListener
HTML:
<title>Jake's Game</title>
<link rel="icon" href="iconname.gif" type="image/gif">
<body>
<div class="WhiteBackground">
<div id="Input" class="center">
<p>Player 1</p>
<input type="text" id="Name1">
<br>
<p>Player 2</p>
<input type="text" id="Name2">
<br>
<p>Player 3</p>
<input type="text" id="Name3">
<br>
<p>Player 4</p>
<input type="text" id="Name4">
<br>
<button id="StartGame">Start Game</button>
</div>
<div align="center">
<p id="Turn"></p>
<table>
<tr>
<th></th>
<th id="Player1">Player 1</th>
<th id="Player2">Player 2</th>
<th id="Player3">Player 3</th>
<th id="Player4">Player 4</th>
<th>Shop</th>
</tr>
<tr>
<td>Gold</td>
<td id="Gold1"></td>
<td id="Gold2"></td>
<td id="Gold3"></td>
<td id="Gold4"></td>
<td>
<button id="NoBuy">N/A</button>
</td>
</tr>
<tr>
<td>Miners</td>
<td id="Miners1"></td>
<td id="Miners2"></td>
<td id="Miners3"></td>
<td id="Miners4"></td>
<td>10000 Gold</td>
</tr>
<tr>
<td>Wood</td>
<td id="Wood1"></td>
<td id="Wood2"></td>
<td id="Wood3"></td>
<td id="Wood4"></td>
<td>
<button id="NoBuy">N/A</button>
</td>
</tr>
<tr>
<td>Loggers</td>
<td id="Loggers1"></td>
<td id="Loggers2"></td>
<td id="Loggers3"></td>
<td id="Loggers4"></td>
<td>10000 Gold</td>
</tr>
</table>
<button id="EndTurn">End Turn</button>
</div>
</div>
</body>
的jsfiddle: https://jsfiddle.net/steventang166/gtb74bpr/41/
謝謝,它的工作無法相信我犯了這麼簡單的錯誤。 –
@StevenTang:感謝隊友,請在我的答案中打勾,作爲正確答案! :) –
在7分鐘,我會。 –