我无法用 js 制作积分系统,我需要帮助,我最近开始学习该语言,因此代码中有很多错误。想法——猜一个随机数我也得猜,猜对了就加1分,以此类推。我设法加了 1 分,但代码不起作用。
function checkForm(el) {
stavka = document.getElementById('stavka').value;
randNum = 1 + Math.floor(Math.random() * 2);
const input = document.getElementById('www')
const p = document.getElementById('point')
console.log('мое число: ' + randNum)
console.log('твое число: ' + stavka)
// вот строчки которые нужно доделать \/
point = 0
if(stavka == randNum) {
point++
console.log(point)
p.innerHTML = point
}
// вот строчки которые нужно доделать /\
if(stavka == randNum) {
console.log('win')
input.innerHTML = 'win'
}
if(stavka > randNum) {
console.log('твое число больше')
input.innerHTML = 'твое число больше - losses'
}
if(stavka < randNum) {
console.log('твое число меньше')
input.innerHTML = 'твое число меньше - losses'
}
if(stavka >= 11) {
console.log('менчик ввыоди правильно!')
input.innerHTML = 'менчик ввыоди правильно! - dayn'
}
return false;
}
body{
text-align: center;
background-color: #2e2e2e;
overflow-x: hidden;
}
.wrapper3{
width: 940px;
margin: 50px auto;
}
.panel_pq{
float: left;
background-color: aliceblue;
width: 100px;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.stavka{
height: 30px;
background-color: aliceblue;
font-size: 1rem;
background-clip: padding-box;
border: 1px solid #bdbdbd;
border-radius: 5px;
}
.stavka{
border-radius: 5px;
}
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>casino</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="wapper3">
<div class="panel_pq">
<div class="panel_panel_pq">
<a href="">zxc</a><br><br><br><br><br>
<a href="">zxc</a><br><br><br><br><br>
<a href="/qwe.html">zxc</a><br><br><br><br><br>
<a href="/index.html">home</a>
</div>
</div>
<div>
<form id="1" onsubmit="return checkForm(this)" method="post">
<h4 style="color: antiquewhite;">введи цифру от 1 до 10 <br><br><br> alfa-version</h4>
<input type="text" placeholder="сумма" id="stavka" class="stavka">
<input type="submit" name="submit" value="Готово" class="stavka_2">
<p id="www" style="color: rgba(255, 0, 0, 0.863);">результат</p>
<p id="point" style="color: antiquewhite;">0</p>
<!-- <a href="/money.html"><h3 style="color: antiquewhite;">напоминаю! сюда кидать деньги</h3></a> -->
</form>
</div>
</div>
<script src="main.js"></script>
</body>
</html>
https://bluecoc.online/phonk.html - 如果您需要的话,这是该网站

