Simple HTML Clicker Game - Test Your Speed!
<!DOCTYPE html>
<html>
<head>
<title>Simple HTML Clicker Game - Test Your Speed!</title>
</head>
<body>
<h1>Simple HTML Clicker Game</h1>
<div id='game-container'>
<h2>You have 10 seconds to click the button as many times as you can!</h2>
<button id='click-me'>Click Me!</button>
<p id='score'>Score: 0</p>
</div>
<script>
var score = 0;
document.getElementById('click-me').onclick = function(){
score++;
document.getElementById('score').innerHTML = 'Score: ' + score;
}
setTimeout(function(){
alert('Time's Up! Your score is ' + score);
document.getElementById('click-me').setAttribute('disabled', '');
}, 10000);
</script>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/lntJ 著作权归作者所有。请勿转载和采集!