<!DOCTYPE html>
<html>
  <head>
    <title>Random Number Game: HTML & JavaScript Tutorial</title>
    <style>
        #box {
            width: 100px;
            height: 100px;
            border: 1px solid black;
        }
        .button {
            background-color: #4CAF50;
            padding: 10px;
            font-size: 15px;
            font-weight: bold;
        }
    </style>
  </head>
  <body>
    <h1>Random Number Game</h1>
    <div id='box'>
        <div id='result'></div>
    </div>
    <button type='button' class='button' onclick='randomNumber()'>Click Me!</button>
    <script>
        function randomNumber() {
            let number = Math.floor(Math.random() * 10);
            document.getElementById('result').innerHTML = number;
        }
    </script>
  </body>
</html>
Create Your Own Random Number Game: HTML & JavaScript Tutorial

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

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