.box1{
display: block;
height:20px;
font-size :20px;;
}
function func1(){
let n =parseInt(document.getElementById('n').value);
let b =parseInt(document.getElementById('me').value);
let r =parseInt(document.getElementById('r').value);
console.log(n);
console.log(b);
n=n-b;
console.log(n);
let x = document.getElementById('n');
x.value = n;
alert(n);
if(n<=r){
alert("很遗憾你输了");
}
}
function func2(){
let n =parseInt(document.getElementById('n').value);
let l =parseInt(document.getElementById('l').value);
let r =parseInt(document.getElementById('r').value);
console.log(l);
console.log(r);
let num = Math.ceil(Math.random()*(r-l))+l;
console.log(num);
n=n-num;
console.log(n);
alert(n);
let x = document.getElementById('n');
x.value = n;
if(n<=r){
alert("恭喜你获胜了");
}
}
取宝石游戏
<br>
<img alt="加载失败" width="100" height="150">
<hr>
请输入总的宝石数目n