Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="ru">
- <head>
- <meta charset="UTF-8">
- <title>Угадай число</title>
- </head>
- <body>
- <h1>УГАДАЙ ЧИСЛО в диапазоне (0, 99999)</h1>
- <input type="number" id="myinput">
- <a class="btn" onclick="go()">Проверить</a>
- <p id="result"></p>
- <style>
- body
- {
- background: #C5D0E6
- }
- h1
- {
- background-color: #91a8da;
- text-align: center;
- width: 680px;
- margin-left: 38px;
- }
- #result
- {
- margin-left: 189px;
- font-size: 200%;
- }
- input[type="number"]
- {
- width: 180px;
- height: 35px;
- text-align: center;
- font-size: 100%;
- margin-left: 189px;
- }
- a.btn
- {
- display: inline-block;
- color: rgb(4, 4, 4);
- font-weight: 600;
- text-decoration: none;
- user-select: none;
- padding: .5em 2em;
- outline: none;
- border: 4px solid;
- border-radius: 10px;
- transition: 0.9s;
- }
- a.btn:hover { background: rgba(255,255,255,.9); }
- a.btn:active { background: white; }
- </style>
- <script>
- var rand = getRandomInt(0, 99999)
- function getRandomInt(min, max) {
- min = Math.ceil(min);
- max = Math.floor(max);
- return Math.floor(Math.random() * (max - min)) + min; //Максимум не включается, минимум включается
- }
- function go() {
- var elem = document.getElementById("result");
- var val = document.getElementById("myinput").value;
- if (val < rand){
- elem.style.color = "red";
- elem.innerHTML = "Введите значение больше "+ val ;
- }
- else if (val > rand){
- elem.style.color = "red";
- elem.innerHTML = "Введите значение меньше "+ val;
- }
- else {
- elem.style.color = "green";
- elem.innerHTML = "В точку "+ val + " верно" ;
- }
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment