I have done something similar to this before, and I know this is really close. I'm just trying to make it so that my button increments the javascript variable, and the function then displays the new value.
<html>
<head>
<title>Space Clicker</title>
</head>
<body>
<script type="text/javascript">
int clicks = 0;
function click() {
clicks += 1;
document.getElementById("clicks").innerHTML = clicks;
};
</script>
<button type="button" onClick="click()">Click me</button>
<p>Clicks: <a id="clicks">0</a></p>
</body></html>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…