<html>
   <head>
      <title>Simple HTML Number Game: Click in Order - Play Now!</title>
   </head>
   <body>
      <h1>Simple HTML Number Game</h1>
      <h3>Instructions:</h3>
      <p>Click on the number squares in numerical order.</p>
      <div>
        <button id='1' onclick='clickNumber(1)'>1</button>
        <button id='2' onclick='clickNumber(2)'>2</button>
        <button id='3' onclick='clickNumber(3)'>3</button>
        <button id='4' onclick='clickNumber(4)'>4</button>
        <button id='5' onclick='clickNumber(5)'>5</button>
        <button id='6' onclick='clickNumber(6)'>6</button>
        <button id='7' onclick='clickNumber(7)'>7</button>
        <button id='8' onclick='clickNumber(8)'>8</button>
        <button id='9' onclick='clickNumber(9)'>9</button>
      </div>
      <p>You have <span id='score'>0</span> points!</p>
      <script>
         let score = 0;
         let prevNumber = 0;
         function clickNumber(number) {
            if (number === prevNumber + 1) {
               score++;
               prevNumber = number;
               document.getElementById('score').innerHTML=score;
            }
         }
      </script>
   </body>
</html>

原文地址: https://www.cveoy.top/t/topic/lmlv 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录