我試過多次搜索這個。我已經接近,但還沒有弄清楚。我試圖做的是當用戶達到一定量的點擊時,彈出一個按鈕。HTML和Javascript改變可見性
<!DOCTYPE html>
<html>
<head>
<title>++ Increment</title>
</head>
<body>
<h1>Click the Button</h1>
<input type="button" id="countButton" onclick="hi()" value="Click Me!"/>
<p class="ClickCount">Clicks: <a id="amount">0</a></p>
<input type="button" id="countButton" onclick="store()" value="Store"/>
<input type="button" style="visibility:hidden;" value="Button" id="Sir" />
</body>
</html>
這裏是JavaScript:
var count = 0;
function hi() {
count += 1;
document.getElementById("amount").innerHTML = count;
}
if (count >= 20) {
document.getElementById("Sir").style.visibility = "visible";
}
我想我需要的計數變量分配喜()函數外面,但我不知道該怎麼做(或者如果可能的話)
試着把'if(count> = 20){...}'函數裏面'hi' – Clint