任何人都可以帮我吗?我试图让它在单击按钮时调用click()函数,但没有任何反应。这些警报是为了测试目的,并且当我能够使它工作时,js将被导出到外部js。谢谢=)我不能让我的HTML打电话给我的js
<!DOCTYPE html />
<html>
<head>
<title>Idle Numbers</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
</head>
<body>
<h1>Idle Numbers</h1>
<p>Number Bank: <span id="numberBank">0</span> | Numbers per Second: <span id="NpS">0</span> | Numbers per Click: <span id="NpC">1</span></p>
<button onclick="click()">Click me</button>
<table id="shop">
<tr>
<th colspan="4">Shop</th>
</tr>
<tr>
<td><p>Ones Place <button onclick="onesPurchase" id="buyOnes">25</button></p></td>
<td><p>Tens Place <button onclick="tensPurchase" value="100" id="buyTens">100</button></p></td>
<td><p>Hundreds Place <button onclick="hundredsPurchase" id="buyHundres">250</button></p></td>
<td><p>Thousands Place <button onclick="ThousandsPurchase" id="buyThousands">2500</button></p></td>
</tr>
</table>
<script type="text/javascript">
var nB, NpS, onesValue, tensValue, hundredsValue, thousandsValue;
var NpC = 1;
function click(){
alert("numberBank");
numberBank = nB + NpC;
alert("numberBank");
document.getElementById("numberBank").innerHTML = nB;
}
</script>
</body>
</html>
'的onclick = “使用functionName()”'你看,在错误的开发者控制台。 – epascarello