body {
fontfamily: Arial, sansserif;
margin: 0;
padding: 20px;
}
h1 {
textalign: center;
}
.calculator {
width: 400px;
margin: 0 auto;
border: 1px solid ccc;
padding: 20px;
borderradius: 5px;
}
.formgroup {
marginbottom: 15px;
}
label {
display: block;
marginbottom: 5px;
}
input[type="number"] {
width: 100%;
padding: 5px;
border: 1px solid ccc;
borderradius: 3px;
}
button {
backgroundcolor: 007bff;
color: white;
padding: 10px 20px;
border: none;
cursor: pointer;
borderradius: 3px;
margintop: 10px;
}
.result {
textalign: center;
fontweight: bold;
}
function calculate() {
const homeGoals = parseInt(document.getElementById("homeGoals").value);
const awayGoals = parseInt(document.getElementById("awayGoals").value);
const overUnder = document.getElementById("overUnder").value;
let result;
if (overUnder === "over") {
// 胜分差大于2球
if (homeGoals > awayGoals 2) {
result = `主队胜,预测比分为 ${homeGoals} : ${awayGoals},胜分差 ${homeGoals awayGoals} 球`;
} else {
result = "比赛结果未达到Over条件,无法预测";
}
} else if (overUnder === "under") {
// 胜分差小于或等于2球
if (homeGoals <= awayGoals 2) {
result = `客队胜,预测比分为 ${awayGoals} : ${homeGoals},胜分差 ${awayGoals homeGoals} 球`;
} else {
result = "比赛结果达到Under条件,主队胜";
}
} else {
result = "无效选择,请输入Over或Under";
}
document.getElementById("result").innerText = result;
}